Saltar navegación

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

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 support ticket is created hace 2 años, 11 meses. 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)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por David hace 2 años, 10 meses.

Asistido por: Shane.

Autor
Mensajes
#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
Colaborador

Idiomas: Inglés (English )

Zona horaria: 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.