WordPress Function to Displaying information for logged in users

Displaying information for logged in users

if ( is_user_logged_in() ) {

}

is not working in functions.php file. You can use this code:

if ( !function_exists('is_user_logged_in') ) :

 function is_user_logged_in() {
$user = wp_get_current_user();

if ( $user->id == 0 ){
// This section if user is not logged in
} else {
// This section if user is logged in
}
}
endif;

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *