April 6th in Wordpress by .

WordPress – How to check if user logged in or not?

Often many times, you might be searching for the wordpress code which checks  if the user logged in or not.  Its no brainer and amazingly simple!

There could be at many parts of your site (say in header.php) ,  you want to show only certain links when the user is already registered and logged in like myaccount, logout page.

Here is the code…

<?php
if (is_user_logged_in()) { ?>
<a href="<?php bloginfo("url"); ?>/wp-admin/">My Account</a>
<a href="<?php bloginfo("url"); ?>/wp-login.php?action=logout/">Logout</a>
<?php } ?>

Refer to is_user_logged_in() function in wordpress site.

Similar Posts:

4 Comments

  • chris
    June 1, 2010
  • Mario
    June 3, 2010
  • Fabio Souza
    January 5, 2012
  • someone
    April 7, 2012

Leave A Comment.





Please wrap all source codes with [code][/code] tags. Powered by