Redirect when user is logged in

how do i block logged in users from viewing a specific page meant to logged out users? Or can i do a redirect to other page when the user is logged in. Like, logged out users can access to the homepage, but if a logged in user try to access to it, should be redirected to other page.

  • Luís
    • Support

    Hi steve ,

    Hope you’re doing well today!

    I will suggest you to try redirect the logged in users to other page, you can try this code in your theme functions.php (or via mu-plugin):

    function redirect_my_page()
    global $current_user;

    if ( is_user_logged_in() && ( is_home() || is_front_page() ) )

    add_action('template_redirect', 'redirect_my_page');

    Just replace “‘” with the desired page URL.

    I hope this information has been helpful. If I can help you in this or other related question, please let me know!

    Cheers, Luís

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.