• Hey – how do I make a user logout button or link that appears on the front of the site (I’m using theme twentyten) and redirects back to the home page?

    Thanks!
    Leah

Viewing 4 replies - 1 through 4 (of 4 total)
  • DigitalSquid

    (@twelvefootsnowman)

    <?php wp_loginout('/'); ?>

    Thread Starter leahs2

    (@leahs2)

    Where do I put this code?

    Thank you!

    that depends on where you want the logout to show:

    for instance, you could put it quite visible at the top of the sidebar:

    edit sidebar.php of TwentyTen; find:

    <div id="primary" class="widget-area" role="complementary">
    		<ul class="xoxo">

    change it to:

    <div id="primary" class="widget-area" role="complementary">
    		<?php if ( is_user_logged_in() ) { ?><ul class="xoxo"><li id="logout" class="widget-container">
    				<h3 class="widget-title"><a href="<?php echo wp_logout_url( get_bloginfo('url') ); ?>" title="Logout">Logout</a></h3></li></ul><?php } ?>
    			<ul class="xoxo">

    http://codex.wordpress.org/Function_Reference/wp_logout_url


    or into the bottom line in the footer:
    edit footer.php; find:

    </div><!-- #site-info -->
    
    			<div id="site-generator">

    change it to:

    </div><!-- #site-info -->
    
    			<?php if ( is_user_logged_in() ) { ?><div class="logout" style="float:left;"><a href="<?php echo wp_logout_url( get_bloginfo('url') ); ?>" title="Logout">Logout</a></div><?php } ?>
    
    			<div id="site-generator">

    Thread Starter leahs2

    (@leahs2)

    Hey alchymyth, thanks so much for the detailed reply! I will be doing this shortly…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Logout button or link’ is closed to new replies.