First Login Redirection
-
Hello!
First I want to mention that I love this plugin for it’s simplicity. Thanks a lot, we all should give you a beer :D!
I have a problem, the only one i encountered. I want to redirect users on their first login to a specific page and after, on other logins on homepage, profile whatsoever. I found this code :
function function_new_user($user_id) {
add_user_meta( $user_id, ‘_new_user’, ‘1’ );
}
add_action( ‘user_register’, ‘function_new_user’);The next function will check if it’s the first login and redirect the user.
function function_check_login_redirect($user_login, $user) {
$logincontrol = get_user_meta($user->ID, ‘_new_user’, ‘TRUE’);
if ( $logincontrol ) {
//set the user to old
update_user_meta( $user->ID, ‘_new_user’, ‘0’ );//Do the redirects or whatever you need to do for the first login
wp_redirect( ‘http://www.example.com’, 302 ); exit;
}
}
add_action(‘wp_login’, ‘function_check_login_redirect’, 10, 2);It works only with default wordpress login. What should I modify in order for it to work with clean login? Can you do it for me? Is there any alternative for this piece of code (if it isn’t good)?
Thanks a lot !!!!
The topic ‘First Login Redirection’ is closed to new replies.