Toolset Auto Login

//////////
//Auto log-in new user
 
add_action( 'cred_save_data', 'tssupp_cred_autologin', 10, 2 );
function tssupp_cred_autologin( $post_id, $form_data ){
   
    if ( 123 == $form_data['id'] ) {
      /// Replace 123 with your form 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() );
            }
        }
    }
}

Related posts