Problem: I have a Form that creates new Users. After submitting the Form, I would like my User to be logged in.
Solution:
add_action( 'cred_save_data', 'tssupp_cred_autologin', 10, 2 ); function tssupp_cred_autologin( $post_id, $form_data ){ if ( 12345 == $form_data['id'] ) { if ( !empty( $_POST['user_email'] ) && !empty( $_POST['user_pass'] ) ) { $user = get_user_by( "email", $_POST['user_email'] ); $signon = array( 'user_login' => $user->user_login, 'user_password' => $_POST['user_pass'], 'remember' => true ); $login = wp_signon( $signon, false ); if ( is_wp_error($login) ) { error_log( $login->get_error_message() ); } } } }
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 7 replies, has 2 voices.
Last updated by 5 years, 7 months ago.
Assisted by: Christian Cox.