[wp-trac] [WordPress Trac] #60748: auth_redirect() login check doesn't exist or doesn't work
WordPress Trac
noreply at wordpress.org
Mon Mar 11 13:11:38 UTC 2024
#60748: auth_redirect() login check doesn't exist or doesn't work
------------------------------------+-----------------------------
Reporter: kratosgemini | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Login and Registration | Version:
Severity: normal | Keywords:
Focuses: |
------------------------------------+-----------------------------
The `auth_redirect()` documentation states:
"Checks if a user is logged in, if not it redirects them to the login
page."
[https://developer.wordpress.org/reference/functions/auth_redirect/]
However, unless a call to `auth_redirect()` is wrapped inside a
`is_user_logged_in()` check, then it always sends people to the login page
(even if a user is already logged in).
I don't know if the documentation is incorrect or if there is a bug in the
code.
To reproduce, all you need to do is something like this:
{{{#!php
<?php
add_action( 'wp', function() {
if ( is_page( 2 ) ) {
auth_redirect();
}
} );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60748>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list