WordPress code to determine whether the user is logged in

is_user_logged_in()

illustrate

Returns boolean true or false depending on whether the current visitor is logged in.

parameter

The function does not accept any parameters.

usage

Copy the code The code is as follows:
<?php if ( is_user_logged_in() ) { … } ?>

Example

Use the is_user_logged_in() function to display different output results in the theme file according to the current visitor’s login status.

Copy the code The code is as follows:
<?php

if ( is_user_logged_in() ) {

echo ‘Welcome, registered user!’;

} else {

echo ‘Welcome, visitor!’;

}

?>

The post WordPress code to determine if a user is logged in first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/9473
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment