Created
June 11, 2013 08:39
-
-
Save yogensia/5755345 to your computer and use it in GitHub Desktop.
After registration, login and redirect user to custom page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* After registrartion, login and redirect user to a custom page | |
*/ | |
function auto_login_registration_redirect() { | |
// Login the user automatically | |
$user_login = $_POST['user_login']; | |
$user = get_userdatabylogin($user_login); | |
$user_id = $user->ID; | |
wp_set_current_user($user_id, $user_login); | |
wp_set_auth_cookie($user_id); | |
do_action('wp_login', $user_login); | |
// Redirect somewhere | |
wp_redirect( home_url( '/registration-complete-thanks/' ) ); | |
exit(); | |
} | |
add_action( 'user_register', 'auto_login_registration_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment