How to Check if User is Logged in WordPress

Snippets by IsItWP

Do you want to display a custom message to logged in users? While there’s probably a plugin for this, we have created a quick code snippet that you can use to check if user is logged in and display a register or welcome message in WordPress.


All you have to do is add this code to your theme’s index.php file or in a site-specific plugin:

          if (is_user_logged_in()) { 
                      /* yes user is logged in */
                      /* no user is not logged in */ 

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 24 best WordPress education themes and how to create a multi-page form in WordPress.

Comments  Leave a Reply

  1. Tweets that mention Wordpress Check if user is logged in – wpsnipp.com Wordpress code snippets for your blog -- Topsy.com November 19, 2010 at 8:34 pm

    […] This post was mentioned on Twitter by Constance, Hilda and Natella, WPSNIPP. WPSNIPP said: #wordpress Check if user is logged in http://bit.ly/cVKBto #blog please RT 🙂 […]

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!