Skip Navigation

[Resolved] Auto login after user registration

This support ticket is created 5 years, 1 month 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 18 replies, has 2 voices.

Last updated by katjaL 5 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#1542113

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Katja,

I'm still not able to link to the site as i'm still getting the error 404.

I did however have a look at the code again and it seems to be fine.

If its possible to even setup a test site with your environment or even provide me with a copy of the site so that I can have something to debug would be greatly appreciate.

Please let me know and we can move forward from there.

Thanks,
Shane

#1542151

Really odd. Now I replaced the login address in the other fields too and deleted all the old addresses. Perhaps you didn't notice the rigth address was there in the textarea field. But now I think it should be the right one in all the fields.

#1542205

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Katja,

I've made some changes to the snippet and it should now be working as intended.

/**
* Auto-login new CRED user
*/
add_action( 'cred_save_data', 'tssupp_cred_autologin', 10, 2 );
  
function tssupp_cred_autologin( $post_id, $form_data ){
  
if ( 12788 == $form_data['id'] ) { // Edit as required
if ( !empty( $_REQUEST['user_email'] ) && !empty( $_REQUEST['user_pass'] ) ) {
  
// get the user credentials from the $_POST object
$user = array(
'user_login' => substr( $_REQUEST['user_email'], 0, strpos( $_REQUEST['user_email'], "@")),
'user_password' => $_REQUEST['user_pass'],
'remember' => true
);
$login = wp_signon( $user, false );
  
if ( is_wp_error($login) ) {
error_log( $login->get_error_message() );
}
  
}
}
}

I've tested it on your site and was able to get logged in directly after i've created my user.

Thanks,
Shane

#1542207

Thank you very much Shane! My issue is resolved now. Thank you!