[英]Access Wordpress user info outside Wordpress
我有 Wordpress 站点,现在我正在子域上构建 PHP 应用程序。 我需要获取在 Wordpress 站点上登录的用户的 ID。
我尝试在我的子域中包含 wp-load.php 并尝试:
get_currentuserinfo();
echo 'Hey ' . $current_user->display_name;
但没有结果。
您能否给我一个提示,如何从子域和同一服务器上的 Wordpress 外部访问 Wordpress session 信息?
提前致谢。
使用 wordpress API 将是最好的方法,因为每种情况都是一种情况,不可能完全按照您所说的情况准备好代码,但是请按照有关 Z8A5DA52ED126447D359E70C05AZ721A8A 的文档链接进行操作:
https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/
这里有另一个如何为自定义登录创建端点的示例: 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.