I need help with this case.
How to if a user is logged in are not allowed to access Login page and will be redirected to their Account Page?
I have a WordPress customized login page, and user is logged in still can access by typing /login slug
Here is my code below:
add_action( 'template_redirect', 'redirect_to_specific_page' );
function redirect_to_specific_page() {
if ( is_page('login') && is_user_logged_in() ) {
wp_redirect( is_page('account'), 302 );
exit;
}
}
2
Answers
Idk I have wrong type or something. I have change the
wp_redirect( is_page('account'), 302 );
withwp_redirect( 'account', 302 );
and its fixed. Can anyone explain this?My revision code below:
you can use it on wp action to redirect.