I am trying to protect external php pages (still under the same domain and sub directory of the root WordPress install) using wordpress authentication.
I’m using the Ultimate Member plugin but I think that the standard WP authentication would still apply?
So at the moment I have this:
<?php
require('../../wp-blog-header.php');
define('WP_USE_THEMES', false);
if ( is_user_logged_in() ) {
global $current_user;
get_currentuserinfo();
echo 'You are logged in ' . $current_user->display_name;
} else {
echo 'NOT LOGGED IN!';
}
?>
But regardless of if I am logged in or not I get the echo ‘NOT LOGGED IN!’
Ideally I would like to display the login form if the user isn’t logged in. I will have include_once files to display otherwise for success.
So my php file is 3 sub folders deep and getting the wp-blog-header.php
file successfully but not sure why it’s not picking up that I am logged in. Is it something to do with cookies?
Thanks in advance 😉