Members only site – still need the lost password page accessible

My site requires login before viewing any page and it works great:

function wpse_131562_redirect() {
if ( !is_user_logged_in() )
{auth_redirect();
}}
add_action(‘template_redirect’, ‘wpse_131562_redirect’);

But obviously this means the link to the lost-password page just redirects back to the login page. I’ve tried changing it to:

function wpse_131562_redirect() {
if ( !is_user_logged_in() || (!ispage(‘lost-password’) )) {
{auth_redirect();
}}
add_action(‘template_redirect’, ‘wpse_131562_redirect’);

But it has the same problem, and when I tried to use wp_lostpassword_url it broke completely.

How can I restrict access to everything other than the lost-password page?

Thanks

Read more here:: Members only site – still need the lost password page accessible

Leave a Reply

Your email address will not be published. Required fields are marked *