The code that WordPress USES to determine if a user is logged in

  • 2020-03-31 21:34:26
  • OfStack

Is_user_logged_in ()
instructions
Returns a Boolean value of true or false based on whether the current visitor is logged in.

parameter
This function takes no arguments.

usage
 
<?php if ( is_user_logged_in() ) { ... } ?> 

The sample
Depending on the current visitor's login, the is_user_logged_in() function is used to display the different output results in the topic file.
 
<?php 
if ( is_user_logged_in() ) { 
echo 'Welcome, registered user!'; 
} else { 
echo 'Welcome, visitor!'; 
} 
?> 



Related articles: