Feb10
Checking whether a user is logged in or not in Wordpress
in: Wordpress
I was searching for information on how to check whether a user is logged in or not. Maybe there was some template tag that did this, like is_loggedin(), but I couldn’t find anything. Also, searching for posts or in google didn’t show up anything usefull.
In the codex I stumbled upon the function get_currentuserinfo(). With this function it’s easy to accomplish the user check:
<?php
global $userdata;
if ($userdata) { print ‘logged in’; } else { print ‘not logged in’; }
?>
Maybe there are better solutions I couldn’t find, but this seems to do the trick.