了解用户是否通过ID登录了wordpress [英] Find out if a user is logged into wordpress from id
本文介绍了了解用户是否通过ID登录了wordpress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这个函数。
if(is_user_logged_in()){
echo'Welcome,registered user!';
} else {
echo'Welcome,visitor!';
}
但是我想知道它们是否是一个通过id来实现的功能,所以它将如下所示。
if(is_user_logged_in(1)){
echo'this user is logged in';
}
无法在任何地方找到。
if(is_user_logged_in()=h2_lin>解决方案
){
$ current_user = wp_get_current_user();
if(1 == $ current_user-> ID){
// do staff。
} else {
//做员工。
}
}
I am looking for a function to check if a user is logged into wordpress via their id.
i am aware of this function.
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
} else {
echo 'Welcome, visitor!';
}
but i was wondering if their is a function that does it via id so it would be like the following below.
if ( is_user_logged_in(1) ) {
echo 'this user is logged in';
}
cant find one anywhere.
解决方案
you can go around it like:
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
if ( 1 == $current_user->ID ) {
// do staff.
} else {
// do staff.
}
}
这篇关于了解用户是否通过ID登录了wordpress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文