WordPress.org

Ready to get started?Download WordPress

Forums

Logging out with one click (2 posts)

  1. olyma
    Member
    Posted 3 years ago #

    Hi. I'm trying to customize my admin dashboard to be a one click logout. I've tried writing a plugin/function to allow it, but it still won't do it, so I just got to the point of hacking the wordpress core files. Here's the function, but it still wants me to click on it twice:

    function seelogout() {
    echo "
    <style type='text/css'>
    div#user_info p.hide-if-js {
    display: inline;
    }
    div#user_info div.hide-if-no-js {
    display: none;
    }
    </style>
    ";
    }

    After that failed, I decided to try to hack the core and this worked quite successfully. In the admin-header.php, I commented out the offending core and stuck in what I wanted and it works now:

    <div id="wphead-info">
    <?php /* What I added to the core. */ ?>
    <div id="user-logout1">
    <p style="float:right;"><?php echo "$howdy $links_no_js"; ?></p>
    </div>
    <?php /* End of what I added to the core, beginning of commenting out. */ ?>
    <?php /* was:
    <div id="user_info">
    <p class="hide-if-js"><?php echo "$howdy | $links_no_js"; ?></p>

    <div class="hide-if-no-js">
    <p><?php echo $howdy; ?></p>
    <div id="user_info_arrow"></div>
    <div id="user_info_links_wrap"><div id="user_info_links">

      <?php echo $links_js; ?>

    </div></div>
    </div>
    </div>
    */ ?>
    </div>

    But is there a way for a function to read the html, and then and then reassign it to spit something else out, like I want, or is there someone who might know how to fix the function I wrote so that it will make it be a one click logout.

    Thank you so much!

  2. olyma
    Member
    Posted 3 years ago #

    Okay, I couldn't find any way around it except to alter the WordPress core, but, but, but.... I found a different way to have a function/plugin for it:

    <?php
    /*
    Plugin Name: One Click Logout
    */
    
    function newlogout() {
    ?>
    
    <div style="float:right;z-index:100;position:absolute;right:0px;top:0px;background:white;padding:8px 30px 5px 100px;border:0px;">
    Howdy, 
    
    <?php
        wp_get_current_user();
    	$current_user = wp_get_current_user();
    	if ( !($current_user instanceof WP_User) )
    	return;
        echo ' ' . $current_user->user_login . ' ';
     ?> 
    
     -- <?php echo '<a href="' . wp_logout_url() . '" title="' . esc_attr__('Log Out') . '">' . __('Log Out') . '</a>'; ?>
    
    </div>
    
    <?php
    }
    add_action( 'in_admin_header', 'newlogout' );
    
    ?>

    Since the css couldn't allow it to be customized to be a one click logout, and as an alternative to altering the WordPress core, I just completely covered over it! Also, I couldn't seem force the old logout to completely disappear with a function either, so the above was my solution. It simply places a z-indexed, absolutely positioned, div, immediately visually "pasted" over the old logout. This way, it just sweeps the entire problem under the rug and with a very simple, clean, html, one click logout in it's place. Yay!!!!

    Zen is returning to my Dashboard.

Topic Closed

This topic has been closed to new replies.

About this Topic