Tell us what you are trying to do?
I have created a new user and then creates a CPT record
i use this code:
-------
/** Creaet new cp-Provider when user registers */
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
if ($form_data['id']==2368)
{
$my_post = array(
'post_title' => $_POST['first_name'] . ' ' . $_POST['last_name'] . ' ' . $post_id,
'meta_input' => array(
'wpcf-cp-mem-id' => $post_id,
'wpcf-cp-first-name' => $_POST['first_name'],
'wpcf-cp-last-name' => $_POST['last_name']
),
'post_content' => 'xx',
'post_status' => 'publish',
'post_author' => $user_ID,
'post_type' => 'cp-provider'
);
wp_insert_post( $my_post );
}
}
-------
when the next page loads I am expecting the page to be loggined in.
I have a hook i have used on other pages and but it will not work on this page.
/** signup carer preferences */
add_action( 'cred_save_data', 'tssupp_cred_autologin45', 10, 2 );
function tssupp_cred_autologin45( $post_id, $form_data ){
if ( 2368==$form_data['id'] ) { // Edit as required
if ( !empty( $_POST['user_login'] ) && !empty( $_POST['user_pass'] ) ) {
// get the user credentials from the $_POST object
$user = array(
'user_login' => $_POST['user_login'],
'user_password' => $_POST['user_pass'],
'remember' => true
);
$login = wp_signon( $user, false );
if ( is_wp_error($login) ) {
error_log( $login->get_error_message() );
}
}
}
}