Easy to Style Login/Log Out Button

Here is the code that I’ve been waiting for!! Found here, you can use this to link to the default wp-login.php page using an image, or customize it further to take advantage of the pages generated by plugins like TML.

<?php
global $user_ID;
get_currentuserinfo();
if('' == $user_ID){ ?>
     <a href="/wp-login.php"><img src="button-in.jpg" alt="login" /></a>
<?php }else{ ?>
     <a href="/wp-login.php?action=logout"><img src="button-out.jpg" alt="logout" /></a>
<?php } ?>

Adjustments I made within one of my themes to link to customized pages:

global $user_ID;
get_currentuserinfo();
if('' == $user_ID){ ?>
        <a href="<?php echo get_permalink(6); ?>"><?php echo get_the_title(6); ?></a>
<?php }else{ ?>
	<a href="<?php echo get_permalink(7); ?>"><?php echo get_the_title(7); ?></a>
<?php }

 

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.