问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/28569412/how-do-i-redirect-non-logged-in-users-wordpress