Php 如何从Wordpress中查询的对象ID设置$userID

Php 如何从Wordpress中查询的对象ID设置$userID,php,string,wordpress,Php,String,Wordpress,我正在编辑一个模板,试图向我的页面添加一些条件逻辑 页面模板显示与用户相关的主题 我想添加一段代码,从我们正在查看的页面中获取用户名,然后将其作为字符串用于我的条件语句 我编写的代码如下,但它破坏了我的页面,所以我做错了什么 <?php global // I query the ID and try and set that to the $userID - I think I am doing this wrong, but when I echo the ID it gets th

我正在编辑一个模板,试图向我的页面添加一些条件逻辑

页面模板显示与用户相关的主题

我想添加一段代码,从我们正在查看的页面中获取用户名,然后将其作为字符串用于我的条件语句

我编写的代码如下,但它破坏了我的页面,所以我做错了什么

<?php global
// I query the ID and try and set that to the $userID - I think I am doing this  wrong, but when I echo the ID it gets the correct info.
$userID = get_queried_object()->ID; 
// This is the string I create using the userID which should be from the query above
$memberstatus = get_user_meta($userID,'member_status',true); 

 ?>

稍后我使用IF语句来使用thsi结果(我知道这是有效的),所以我不会发布它们。我的问题是如何让上述方法发挥作用


有什么帮助吗?

damm,当我从php中删除“global”时,它看起来很有效!我认为global必须在这方面……啊,好吧

记住打开错误报告(并显示错误),这样您就可以看到出现的错误。