In this example, user registration followed by automatic login in WordPress To enable auto-login on your site, you can use the Auto Login New User After Registration plugin. After activating the plugin, go to Settings » Auto Login New User After Registration in the WordPress dashboard. This will bring you to the settings page where you can enable auto-login functionality.
1 2 3 4 5 6 7 8 9 10 11 12 | add_action('update_user_metadata', 'my_auto_login', 10, 4); function my_auto_login( $metaid, $userid, $key, $value ) { // We only care about the password nag event. Ignore anything else. if ( 'default_password_nag' !== $key && true !== $value) { return; } // Set the current user variables, and give him a cookie. wp_set_current_user( $userid ); wp_set_auth_cookie( $userid ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.