is_user_logged_in()
is_user_logged_in()
确定当前访问者是否为登录用户。
Determines whether the current visitor is a logged in user.
说明(Description)
有关此主题函数和类似主题函数的更多信息,请参阅主题开发人员手册中的条件标记文章。
返回(Return)
(bool)如果用户已登录,则为True;如果未登录,则为false。
源码(Source)
/** * Checks if the current visitor is a logged in user. * * @since 2.0.0 * * @return bool True if user is logged in, false if not logged in. */ function is_user_logged_in() { $user = wp_get_current_user(); return $user->exists(); } endif; if ( !function_exists('auth_redirect') ) :
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
2.0.0 | wp-includes/pluggable.php:1012 | 44 | 1 function |
笔记(Notes)
示例:根据用户是否登录,显示不同的输出。
请注意,is_user_logged_是一个可插入的函数,如果过早调用它,可能会出现致命错误。
示例:从您的函数文件中,此代码显示登录用户的个人消息。
is_user_logged_in() 为WP2原创文章,链接:https://www.wp2.cn/functions/is_user_logged_in/