ThePhotoChest
ThePhotoChest

Reputation: 3

How do i redirect non logged in users Wordpress

I am looking to redirect users who are not logged in on any page of my WordPress website to a /welcome page which will have a sign up form on. This is pretty essential as it is a small social networking site.

I am also trying to do this without having any redirect loop issues so my users can easily get to the /welcome page without any hassle.

Upvotes: 0

Views: 1102

Answers (1)

danbahrami
danbahrami

Reputation: 1012

Put this in your header.php file

if( !is_user_logged_in() && !is_page( 'welcome' ) ) {

    wp_redirect( bloginfo( 'url' ) . '/welcome' );
    exit;

}

Hope that helps

Regards

Dan

Upvotes: 1

Related Questions