I have have a custom join page that is called /join/ and the page id=484 and it uses a plugin for the registration function by simply placing a shortcode on the page very straight forward.
I need to automatically log in the user after the register and send them to a specific page. So I have created a function which works but, it also gets triggered when i'm logged in as admin and go to add new user or use the function wp_insert_user().
Here is the code that works but how do I limit the auto login to only function when they are coming from page called 'join'.
function auto_login_new_user( $user_id ) {
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id, false, is_ssl()) ;
wp_redirect( 'http://example.com/special.php' );
exit;
}
add_action( 'user_register', 'auto_login_new_user',10,1 );
Now this code doesn't work when I tell it to execute on the page id 484 why?
function auto_login_new_user( $user_id ) {
if (is_page('484')){
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id, false, is_ssl()) ;
wp_redirect( 'http://example.com/special.php' );
exit;
}
}
add_action( 'user_register', 'auto_login_new_user',10,1 );