• Hi,

    I would like to know how I can redirect a user from a certain page if they are not logged please? I have a “profile page” that nobody should be able to access if they are not logged into WordPress.

    Never mind…as I was typing this I tried a few things and this seems to work on the template I am using.

    <?php
    /*
    Template Name: Profile Page
    */
    
    // check if user logged in
    if ( is_user_logged_in() ) {
        echo '';
    } else {
        wp_redirect( home_url() );
        exit;
    }
    ?>
  • The topic ‘Redirect a user from a certain page if they are not logged in.’ is closed to new replies.