How to check if a WordPress user is logged in

Here’s is a quick tip which allows you to check if the current visitor is logged in. you can use this snippet to display different content based on whether the user is logged in or not.

//Check if user is logged in or not
if ( is_user_logged_in() ) {
	echo 'Welcome, registered user!';
} else {
	echo 'Welcome, visitor!';

Useful Read: Retrieving featured image URL


Leave a Comment.