Check the WordPress user status on any template

Ever wanted to check if a user is logged into the website and display a different set of menus, welcoming text or restricted area?

This is quite easy to do using some simple PHP and some WordPress prebuilt features. Try the following code on any page in your custom template and you should see it working right away.

if(is_user_logged_in()) {
 echo "Hi I am logged in" ;
 echo "Oh no I am not logged in" ;
The easiest way to get the WordPress login status of a user trying to log into WordPress.
User logging into WordPress!

Do you have a better way of programming the above function? Please let us know in the comments below, we would love to hear from you.

Are you after a fully customised WordPress service? visit our WordPress Services page or contact us for an obligation free quote.

If you have any problems or queries please join our Discord community by clicking this link.