Skip to content

Instantly share code, notes, and snippets.

@yogensia
Created June 11, 2013 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yogensia/5755345 to your computer and use it in GitHub Desktop.
Save yogensia/5755345 to your computer and use it in GitHub Desktop.
After registration, login and redirect user to custom page
/**
* 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