For those who has the problem with is_user_logged_in()
in Wordpress returning only false
, One of unexpected reason is the server is not getting Authorization header.
You might need to see all request headers by printing this code:
<?php
...
print_r(getallheaders());
If you don't see Authorization
header, then your problem is not the script, but the .htaccess
file instead.
You gonna need to add these lines on your .httaccess
file:
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1