Strange behaviour of is_user_logged_in()


I have an issue where is_user_logged_in() appears to alternate between being true and false. Here’s my code:


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^wp-content/uploads/(.*)$ file-access.php?file=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress



if ( is_user_logged_in() ) {
    // User is logged in, proceed.
} else {
    // User is a guest, block.

I’ve verified the alternating status using some error logging in the file-access.php conditionals.

Do I need to call something other than wp-load.php perhaps? Just seems strange to me that it alternates between true and false, rather than always being false…

, , warm__tape 9 months 0 Answers 58 views 0

Leave an answer