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:
- 10 Useful WordPress User Interface / Dashboard Hacks!
- WordPress – How to create a login protected page?
- How to show adsense on specific posts/pages in WordPress?
- WordPress – How to email user when post is published?
- How to assign or remove user permissions in WordPress
- WordPress – Retrieve author/user details from Post ID
- Tutorial: How to write a WordPress Plugin?
- How to redirect when post submitted for review in WordPress
- How to insert logo in your wordpress blog?
- WordPress – how to add custom field when post is published?


June 1, 2010
Exactly the code I was looking for. I want to show people who are logged in certain links not just the ones the general public see.
June 3, 2010
Now I’m able to to do what I ever wanted before, thanks!
January 5, 2012
Thanks!
April 7, 2012
Lifesaver! thank ya