Redirect is not native
-
I’m working whit a snippet, which let’s you redirect at first time to some “welcome new user” page. If some new user login with wordpress default access, the snippet works perfectly. But when you login the first time with “login with ajax”, inmedtiatly after registry, the snippet not working.
Here is the code I’m using://hook when user registers add_action( 'user_register', 'myplugin_registration_save', 10, 1 ); function myplugin_registration_save( $user_id ) { // insert meta that user not logged in first time update_user_meta($user_id, 'prefix_first_login', '1'); } // hook when user logs in add_action('wp_login', 'your_function', 10, 2); function your_function($user_login, $user) { $user_id = $user->ID; // getting prev. saved meta $first_login = get_user_meta($user_id, 'prefix_first_login', true); // if first time login if( $first_login == '1' ) { // update meta after first login update_user_meta($user_id, 'prefix_first_login', '0'); // redirect to given URL wp_redirect( 'http:domain.com/welcome-page' ); exit; } }
So, I assume the login with ajax is using its own redirect after login, and not the native redirection. There is any way to fix this?
Best regards.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Redirect is not native’ is closed to new replies.