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 :


 <?php
if ( is_user_logged_in() )
 {

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

    echo 'Welcome, registered user!';

} 
else 
{
//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!

Advertisements

Sr. Software Engineer

Tagged with: , ,
Posted in Wordpress

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: