• Is there a way to automatically login a user when he clicks the confirmation link sent? Instead of getting an “account confirmed” message I want the user to be automatically logged in and redirect do a certain page

    • This topic was modified 4 years, 9 months ago by Nadav Cohen.
Viewing 1 replies (of 1 total)
  • Plugin Support sanjuacharya77

    (@sanjuacharya77)

    Hi @amaa,

    Please paste this code in your active theme’s functions.php file at the end to automatically login to a user when he clicks the confirmation link sent.

    Here is the code:

    //auto log in the users to my account page after clicking in the verification link
    
    add_action( 'user_registration_check_token_complete', 'ur_auto_login_email_verification', 10, 2 );
    
    function ur_auto_login_email_verification( $user_id, $user_reg_successful ) {
    
    	if( true === $user_reg_successful ) {
    
    		wp_set_auth_cookie( $user_id );
    
    		wp_safe_redirect( ur_get_page_permalink( 'myaccount' ) );
    
    		die();
    
    	}
    
    }

    Do Let me know if it helps or not and I will get back to you.

    Regards!

Viewing 1 replies (of 1 total)
  • The topic ‘Auto Login’ is closed to new replies.