WordPress check if user is logged in

27.Sep.2010

When making customization for our WordPress theme, often we need to check if user is logged in. It is a simple task when using a WordPress function is_user_logged_in().

Here is a simple snippet that shows you how to check if user is logged in or not.

1
2
if(is_user_logged_in()) echo 'You are logged in.';
else echo 'You are not logged in.';