How to check user logged in or not in wordpress?

Hello Everyone!

I am come back with a new information.

If you are planning to set a different-2 custom message for registered and guest user then use my code given below :

if ( is_user_logged_in() )

//go here when user is logged in
//message for registered user

    echo 'Welcome, registered user!';

//Go here when user not logged in
//message for guest user    
  echo 'Welcome, visitor!';


Copy and paste my code anywhere in our wordpress theme files where you want to set this condition.

Enjoy Code!


Sr. Software Engineer

Tagged with: , ,
Posted in Wordpress

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Recent Posts
%d bloggers like this: