How do i redirect non logged in users Wordpress

£可爱£侵袭症+ 提交于 2019-12-12 06:07:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!