Skip Navigation

[Resolved] Auto login user after cred from submit with system generated password

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to be able to automatically log in their users when they sign up using our Toolset Forms with the autogenerated passwords.

Solution:
Unfortunately the only way this will work is if the user creates their password. This will not work with autogenerated passwords as there is no way for us to access that autogenerated password.

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)

This topic contains 2 replies, has 2 voices.

Last updated by David 1 year, 10 months ago.

Assisted by: Shane.

Author
Posts
#2402227

Hi there,
I'm using a snippet targetting my form that works to automatically login the user after registration form submission:

add_action( 'cred_save_data', 'tssupp_cred_autologin', 10, 2 );
function tssupp_cred_autologin( $post_id, $form_data ){
if ( 64710 == $form_data['id'] ) { // Edit as required
if ( !empty( $_POST['user_email'] ) && !empty( $_POST['user_pass'] ) ) {
$user_login = explode("@",$_POST['user_email']);
$user = array(
'user_login' => $user_login[0],
'user_password' => $_POST['user_pass'],
'remember' => true
);
$login = wp_signon( $user, false );
if ( is_wp_error($login) ) {
error_log( $login->get_error_message() );
}
}
}
}

Instead of user created password, I want to use a system generated password.
I can change the setting of the form, but how should I modify the snippet so that it works with a system generated password.
Thanks.

#2402305

Shane
Supporter

Languages: English (English )

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

Hi David,

Thank you for getting in touch.

Unfortunately the only way this will work is if the user creates their password. This will not work with autogenerated passwords as there is no way for us to access that autogenerated password.

Thanks,
Shane

#2404139

OK, thanks for confirming that.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.