Login only redirect in Wordpress

Wednesday, November 4, 2015

What I'm trying to achieve:
I don't want any of the pages accessible to anyone without a password. The problem with any of login only redirect plugins is that they redirect even the lost password url. I tried adding the following code above to my header. The page does allow the redirect to the lost password url, but the content of the page doesn't load.



What I'm trying:



global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
if ( !is_user_logged_in() && $current_url !== wp_lostpassword_url() ){
auth_redirect();
}


I had also tried adding return; but that didn't work either.

0 comments:

Post a Comment