I need to call a PHP script external to WP and I would like to take advantage of the credentials of WP so that only logged users can access this script. I have tried to use this code embedded in my external PHP script but it would not work (where XXX is the domain name):
require('/var/www/vhosts/xxx.xxx.xxx/httpdocs/wordpress/wp-blog-header.php');
if ( !is_user_logged_in () ) {
//the script exits if the user is not logged in
showAccessDenied($day, $month, $year, $area, isset($room) ? $room : "");
exit;
}
Do you have any clue? Many thanks in advance!!