Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/is user logged in


This Conditional Tag checks if the current visitor is logged in. This is a boolean function, meaning it returns either TRUE or FALSE.


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


This function does not accept any parameters.

Return Values

True if user is logged in, false if not logged in.


Display different output depending on whether the user is logged in or not.

if ( is_user_logged_in() ) {
	echo 'Welcome, registered user!';
} else {
	echo 'Welcome, visitor!';

From your functions file, this code displays a personal message for logged in users.

add_action( 'loop_start', 'personal_message_when_logged_in' );

function personal_message_when_logged_in() {

    if ( is_user_logged_in() ) {
        $current_user = wp_get_current_user();
        echo 'Personal Message For ' . $current_user->user_login . '!';
    } else {
        echo 'Non Personalized Message!';


Change Log

Since: 2.0.0

Source File

is_user_logged_in() is located in wp-includes/pluggable.php.


Login Tags: is_user_logged_in(), wp_login_form(), wp_loginout(), wp_logout(), wp_register()
Login URLs: wp_login_url(), wp_logout_url(), wp_lostpassword_url(), wp_registration_url()

See also index of Function Reference and index of Template Tags.