Skip Navigation

[Resolved] Keeping page logged in

This support ticket is created 5 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 1 voice.

Last updated by Mario 5 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#1263379

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() );
}

}
}
}

#1263493

My issue is resolved now. Thank you!