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
How to password protect wordpress site?
Collapse
X
-
-
I don't want to do that. I have a website with around 10 pages. I only want to display home page to visitors and rest of the pages should be visible to logged in users only. If a visitor tries to access another page they should be redirected to login page. I just installed a plugin PASSWORD PROTECT PLUGIN FOR WORDPRESS. It is redirecting visitors to login form for all pages including home page. I want to display home page to visitors. This is the code :
function password_protec ted() {
if ( (!is_user_logge d_in() and !is_feed()) or (!is_home() and !is_front_page( )) or (!is_user_logge d_in() and is_feed() and !get_option("wp passprotect_pub lic_feed")=="ch ecked")) {
auth_redirect() ;
}
}
In this code, I added (!is_home() and !is_front_page( )) myself to allow visitors to see home page but it's not working. Am I doing something wrong?Comment
-
Hello rizwanrajput,
Just try with the following function.
Code:function password_protected() { if(!is_home() or !is_front_page()) { if ( (!is_user_logged_in() and !is_feed()) or (!is_user_logged_in() and is_feed() and !get_option("wppassprotect_public_feed")=="checked ")) { auth_redirect(); } } }
Thanks & Regards,
Mayur BhayaniComment
Comment