[英]calling wp_current_user() in wordpress makes non jquery
I am creating website in WP with s2member plugin.I used these few lines inside where I used the s2member member code 我正在使用s2member插件在WP中创建网站。我在使用s2member成员代码的地方使用了这几行
$current_user = get_current_user_id(); / get current looged in user ID
$_SESSION['id']=$current_user; // put that in session
I have queries that is this the right way to set session in WP? 我有疑问这是在WP中设置会话的正确方法吗? (I used set_session on top) Results:
(我在上面使用了set_session)结果:
The grey bar on top of WP that shows current logged in user becomes complete blank,it doesn't show any logged in user. WP顶部显示当前登录用户的灰色条变为完全空白,它不显示任何登录用户。
I thnk that there is different way to set session in WP or it doesn't allow you to do so.. Any help in this regard. 我认为在WP中设置会话有不同的方法,或者它不允许你这样做..在这方面有任何帮助。 Thanks
谢谢
Not sure of the context where this is being used, but two things: 不确定使用它的上下文,但有两件事:
'id'
is too much of a common argument, used everywhere, try 'u_id'
'id'
是一个常见的论点,无处不在,试试'u_id'
It comes to mind because of this WordPress Answer: List of reserved names in $_POST and $_REQUEST used by WordPress 3.5 因为这个WordPress答案: WordPress 3.5使用的$ _POST和$ _REQUEST中的保留名称列表
$current_user
is a global WordPress core variable, use another name. $current_user
是一个全局的WordPress核心变量,使用另一个名称。 And as suggested in the linked Answer, prefix everything . 并且如链接的答案所示,为所有内容添加前缀 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.