简体   繁体   English

在 Wordpress 之外访问 Wordpress 用户信息

[英]Access Wordpress user info outside Wordpress

I have Wordpress site and and now I'm building PHP App on subdomain.我有 Wordpress 站点,现在我正在子域上构建 PHP 应用程序。 I need to get ID of the user who is logged in on Wordpress site.我需要获取在 Wordpress 站点上登录的用户的 ID。

I tried to include wp-load.php on my sub-domain and tried:我尝试在我的子域中包含 wp-load.php 并尝试:

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?您能否给我一个提示,如何从子域和同一服务器上的 Wordpress 外部访问 Wordpress session 信息?

Thanks in advance.提前致谢。

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:使用 wordpress API 将是最好的方法,因为每种情况都是一种情况,不可能完全按照您所说的情况准备好代码,但是请按照有关 Z8A5DA52ED126447D359E70C05AZ721A8A 的文档链接进行操作:

https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/ 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这里有另一个如何为自定义登录创建端点的示例: 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 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM