I'm looking at creating a Logout link in the Wordpress admin menu that when clicked the user is logged out immediately.

I don't want the Logout link to be a submenu of an existing menu, I just want it to be the last item that appears on the menu.

Any ideas?

Thanks in advance.

  • What research have you done so far. Please add the code that you have so far – Pieter Goosen Apr 16 '14 at 11:44
  • 1
    Hi Pieter, I've looked at this - wordpress.stackexchange.com/questions/51157/… but this redirects to a page with a quote in the meantime. What @TheDeadMagic has created is great, except I'm wanting the logout ini the admin side panel to the left, not the top admin toolbar. – David Apr 16 '14 at 12:19

You can use the awesome WP_Admin_Bar & hook in with admin_bar_menu:

 * Add a "Log out" link directly to the admin bar.
 * @link    http://wordpress.stackexchange.com/q/141446/1685
 * @param   WP_Admin_Bar    $wp_admin_bar
function wpse_141446_admin_bar_logout( $wp_admin_bar ) {
    if ( is_user_logged_in() ) {
                'id'     => 'my-log-out',
                'parent' => 'top-secondary',
                'title'  => __( 'Log out' ),
                'href'   => wp_logout_url(),

add_action( 'admin_bar_menu', 'wpse_141446_admin_bar_logout', 100 );
| improve this answer | |
  • That's excellent! But... how do I get it in the admin menu on the side? – David Apr 16 '14 at 11:53
  • Just add 'parent' => 'top-secondary' (see revised answer). – TheDeadMedic Apr 16 '14 at 13:08
  • Hmm, thanks for this, but I mean the sidebar admin panel, the one with Pages, Posts, Media, Links etc. – David Apr 16 '14 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.