我有WP& yii2应用程序安装在同一服务器上,同一个域。我想从yii2应用程序中获取WP当前登录用户。 有什么想法吗?
答案 0 :(得分:1)
试试这个:
require_once('../../../wp-config.php');
require_once('../../../wp-includes/wp-db.php');
require_once('../../../wp-includes/pluggable.php');
echo wp_get_current_user()->ID;
只需确保路径正常,以便您能够成功要求文件。