开发者

How to password protect wordpress site?

开发者 https://www.devze.com 2023-01-27 05:30 出处:网络
I need to password protect my wordpress site except home page. I need homepage to be visible to every开发者_开发技巧 visitor but if they click on ANY link that could be post/page within the site then

I need to password protect my wordpress site except home page. I need homepage to be visible to every开发者_开发技巧 visitor but if they click on ANY link that could be post/page within the site then user should be redirected to login page. Any help would be appreciated


<?php
if (is_user_logged_in()){
    echo "Welcome, registered user, here are my lovely posts";
}
else {
    header( 'Location: http://www.yoursite.com/login.php' ) ;
};
?>


Just a bit of edit to benhowdle89's code..

<?php
if (is_user_logged_in() || is_home()){
    echo "Welcome, registered user, here are my lovely posts";
}
else {
    header( 'Location: http://www.yoursite.com/wp-login.php' ) ;
};
?>


WordPress › Absolute Privacy « WordPress Plugins

0

精彩评论

暂无评论...
验证码 换一张
取 消