$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>functions - Members only site - still need the lost password page accessible|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

functions - Members only site - still need the lost password page accessible

matteradmin8PV0评论

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

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

Share Improve this question edited Dec 7, 2018 at 17:39 Lyall asked Dec 7, 2018 at 15:39 LyallLyall 1351 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

I believe your if statement is incorrect it should be an AND (&&) not OR

so try

if ( ! is_user_logged_in() && ! is_page( 'lost-password' ) ) {

EDIT

Try using $object = get_queried_object() for checking the post slug

$object = get_queried_object();
if ( ! is_user_logged_in() && ( ! $object || 'my-account' !== $object->post_name ) ) {
  // ...

EDIT 2 The page slug was wrong so updated in the second example

Post a comment

comment list (0)

  1. No comments so far