0

I have Wordpress site and and now I'm building PHP App on subdomain. I need to get ID of the user who is logged in on Wordpress site.

I tried to include wp-load.php on my sub-domain and tried:

get_currentuserinfo();
echo 'Hey ' . $current_user->display_name;

But no result.

Could you please give me a hint how can I access Wordpress session info from outside Wordpress on Sub-domain and on the same server?

Thanks in advance.

Sergi Khizanishvili
  • 537
  • 1
  • 7
  • 16

1 Answers1

0

Using the wordpress API would be the best way and as each case is a case it's not possible to get code ready for exactly what you say, but follow the documentation link about the api part that can help you:

https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/

here you have another example of how to create endpoints for custom logins: Register/login user with Wordpress JSON API

And this other one here of how to create a php request curl on another site that in your case would be the wordpress API: https://phpenthusiast.com/blog/five-php-curl-examples

Kelvin Mariano
  • 991
  • 8
  • 15