Article Feed

Managing state in wordpress

Sometimes we want to display a different button for when you are logged-in (logged-in state) and another for when you are not.. (See pictures)

loginbtnlogoutbtn

/*we figure out if user is logged in?  If not logged in, show  login button, else show logout button */

<?php  if (is_user_logged_in()){
<a class="logoutbtn" href="http://<yoursitename>/ wp-login.php?logout"> logout </a>
         }
         else {
<a class="loginbtn" href="http://<yoursitename>/ wp-login.php"> login </a>
           };
?>
 

Instead of styling the link classes, you can also just change the text message to say whatever you want.

Lakshmi Mareddy is a polyglot from South India and is interested in design, technology, UI and human computing. She also is a history buff and an avid reader. If you like the way she writes, why dont you subscribe to the site feed via RSS or Email? Its absolutely free and helps you stay current. You can contact her via the contact page or write to lak [at] mareddy [dot] com.

one
comment

31 Oct 20077:15 am
 
01
mybloglog avatar
Shinade said

Thank you for the lovely invite to come see your new look. Whiuch by the way is fabulous. Of course it was lovely before. But, it always feels good to get a make over huh? You did an excellent job. And Happy Halloween to you also!! Blessings of peace!

 
Share your thoughts

Note: Your comments may take time to appear, as they are moderated for the first time.. All comments are followed. Your Personal Info will not be shared. Still have concerns? Read the rights and privacy details of Chilligavva..

 
Security Image
 
CommentLuv Enabled