4

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

 2 years ago
source link: https://blog.p2hp.com/archives/9473
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

WordPress判断用户是否登录的代码 | Lenix Blog

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

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

复制代码 代码如下:
<?php if ( is_user_logged_in() ) { ... } ?>

示例
根据当前访问者的登录情况,使用is_user_logged_in()函数在主题文件中展示不同输出结果。

复制代码 代码如下:
<?php
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
} else {
echo 'Welcome, visitor!';
}
?>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK