Home  >  Article  >  Backend Development  >  WordPress判断用户是否登录的代码_PHP

WordPress判断用户是否登录的代码_PHP

WBOY
WBOYOriginal
2016-06-01 12:17:05916browse

WordPress

is_user_logged_in()
说明
根据当前访问者是否登录返回布尔值true或false。

参数
该函数不接受任何参数。

用法
复制代码 代码如下:


示例
根据当前访问者的登录情况,使用is_user_logged_in()函数在主题文件中展示不同输出结果。
复制代码 代码如下:
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
} else {
echo 'Welcome, visitor!';
}
?>


参考链接:Function Reference/is user logged in

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn