Remove Admin Bar For Subscribers

You might want open registration on your WordPress site so that (for one small example) people can log in and leave comments on things without needing to type their name/url/email every time. But these users probably don't need to see the whole top admin bar as there likely isn't much use in it for them. Although do be sure to provide a link to edit their profile and log out.

This would be for your functions.php file or functionality plugin:

add_action('set_current_user', 'cc_hide_admin_bar');
function cc_hide_admin_bar() {
  if (!current_user_can('edit_posts')) {


  1. User Avatar
    Permalink to comment#

    Didn’t work for me. It still shows up for all users. Is it a problem with the set_current_user hook? I ended up using on of the options in this article:

  2. User Avatar
    Lars Koudal
    Permalink to comment#

    Hiya, just wanted to let you know your code works fine in 3.5.1 Admin bar shows up for admins, but not normal subscriber level users.

  3. User Avatar
    Cody Martens

    I couldn’t get it to work. set_current_user is a depreciated function. I hooked it to wp_footer instead and it did the trick. Although, it’s still adding 28px padding to the top of the html tag.

  4. User Avatar
    Permalink to comment#

    i’m using S2 member plugin, can i use this code in function.php…?

  5. User Avatar
    Permalink to comment#

    I got it to work for me. Thanks a ton.

  6. User Avatar
    Permalink to comment#

    Finally got it. The Admin WP bar is removed. Good article.

  7. User Avatar
    Permalink to comment#

    Just type in wp-content/themes/mytheme/functions.php the following:

    Swap mytheme for the name of your theme’s folder.

  8. User Avatar
    Permalink to comment#

    Worked perfectly, placed in my child functions.php

  9. User Avatar
    Permalink to comment#

    Worked on desktop, not on an iPad Air 2 though.

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.