Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Disable WordPress Admin Bar for All Users Except Administrators

Last updated on by
Follow WPBeginner on YouTube
How to Disable WordPress Admin Bar for All Users Except Administrators

Recently while working on a membership site, we had to create multiple level of users. We did not want the users to have access to the WP-Admin panel because it was not customized for their experience. Rather we had put everything necessary (such as edit profile page), user dashboard etc, on the front-end. While S2 Membership Plugin allowed for us to disable wp-admin access for all users except for admins, there was no option to disable the admin bar by default. In this article, we will show you how to disable WordPress admin bar for all users except for Administrators.

Video Tutorial

If you don’t like the video or need more instructions, then continue reading.

Disable Admin Bar for All Users Except for Administrators

Paste this code in your theme’s functions.php file or your site-specific plugin.

add_action('after_setup_theme', 'remove_admin_bar');

function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {

Disable Admin Bar for All Users

If you want to disable it for all users, then simply put use this code in your theme’s functions.php file or your site-specific plugin.

/* Disable WordPress Admin Bar for all users but admins. */

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Terry Hale says:

    Thanks so much for this! No plugins, nice, clean, simple.

  2. WPBeginner Staff says:

    WordPress admin bar is displayed only for logged in users.

  3. Bhris says:

    Great straight-to-the-point tutorial.

    Is there a version of the code that will block all non-users. That is, visitors to the site won’t see the bar, while all logged-in users would?

  4. Shashi says:

    I was trying to do what what was mentioned in the article and it did not work. I used the following instead which did the trick from me:

    if ( ! current_user_can( ‘manage_options’ ) ) {
    show_admin_bar( false );

    The above was mentioned in the wordpress codex:

  5. kim04099 says:

    Thank You!!

  6. Che Boielle says:

    Fastest fix to an odd issue I’ve ever found and implemented. Great explanation simple to follow instructions. Thanks guys, will be book marking your site.

  7. Manthan says:

    Thanks, Its the easiest way found..!!!

  8. Ryan McGovern says:

    Thanks for the code snippet!

  9. Anup says:

    Why not simply do this for any specific user.

  10. Róger Marroni says:

    Great job man!

    thank you very much!

  11. Mega says:

    I tried and my site is black.

  12. Etienne says:

    Perfect piece of code… Thanks a lot!


  13. Nathan Jansen says:

    Use this if you want this only for a certain role

    function remove_admin_bar() {
    $user = wp_get_current_user();

    if (in_array(‘subscriber’, $user->roles)) {

  14. meef says:

    Godbless You. Answers to my problem always come from you post.


  15. Prem says:

    Finally I got the answers Thank you

  16. Paw Pet Directory says:

    I used this on my directory for my customers but the bar will not go away for them. I am using 3.8 with AppThemes Vantage Theme (Latest)

  17. Cory says:

    This is one of those things that, because it’s such a small customization, I’d hate to use a plugin for. So being able to throw this short piece of code into my child theme’s functions.php made me super happy. Thanks so much far sharing! Works like a charm.

  18. Raman says:

    Thanks for posting it was useful.

  19. Naveen says:

    I have added this code it is working fine, but if a user takes meta there is an option yo view the admin, if i click on this the admin page can see, how to avoid this, i dont want to give admin panel to the users, a user can edit the url and give /wp-admin also he can see the admin, i dont want both what will do for this?

  20. Subodh says:

    Admin bar is hidden but now how can a user log out?
    I am using bbpress forum and a plugin for users to log in via their Facebook account to join forum. But find no option for logging out.

  21. Loralee says:

    Thanks for the great tutorial. I thought it didn’t work – and then silly me I hadn’t followed the last step to activate my new plugin!! Thanks so much for this! So much better than installing multiple new plugins.

  22. vikas says:

    Thanks mate….u were really helpful…
    tc :-)

  23. Rajat says:

    Thx syed it just worked perfectly

  24. Bongo says:

    Thanks for this, it helped me a lot

  25. Andy Wagstaff says:

    I have an area of my site that requires log-in registration.
    I have made the admin bar “autohide” by requiring a plug-in, I don’t want to entirely disable it, as I need the abiity to change password, but is there any way of removing items from the bar for users? I don’t want the site name,WP logo or the theme extensions options on the left hand side.

    Is this possible? I am sure it is, but I can’t work it out!!

    Ta!! Really handy site by the way


  26. Rajiv says:


    I want to disable BP Admin Bar for Logged Out Users.

    Please help.

  27. Ken Shoufer says:


    Your code worked fine when I tried it locally on my computer, but when I tried it on a fresh WordPress install on my host server it would not let me log out. When I tried to log out, the address showing was “″.

    I’m not sure what is wrong.

  28. Adrian says:


  29. Fabio Santos says:
  30. Nate says:

    i am trying to disable the W logo on the top left, the “My Sites” menu and the dashboard link on a buddypress multisite install. I want to keep the right side functional which shows the links to their buddypress profile settings. How can I achieve this?

  31. Tanner Moushey says:

    To avoid the blank space where the admin bar was, call the function in the “after_setup_theme” action instead of “init”.

  32. Cristian B. says:

    Really nice code. Are here also a fix to the blank bar that many here complains?

  33. niki says:

    Fantastic! Except I also have the blank space visible where the admin bar would be. Does anyone have a fix for this?

  34. Marlita Hill says:

    Hello. Thank you for this. How would I write the code if I only want the bar accessible to admin and contributors? I still do not want the contributors to have admin access to my backend.

  35. Steve says:

    Well… it removes the admin bar but it´s still occupying the space meaning there´s too much space up there now. I´m not sure it´s supposed to be that way? ;-)

  36. Adam says:

    worked …
    Thanks a lot

  37. Nick Cokas says:

    Add the code and worked perfect. However, the user still sees a white space above were the toolbar existed before. Any ideas to remove that.


  38. Toby Couchman says:

    Did you use a plugin to place all the necessary user stuff on the frontend?

    My team recently built a site with similar requirements and I’d love to compare the processes.


  39. Mark Coleman says:

    Do not pass a role name to current_user_can(), as this is not guaranteed to work correctly. from

    just FYI

    • Editorial Staff says:

      Agreed. Just updated the code to make it into a function, and then adding it in via action.

  40. Sally says:

    Excellent post thanks so much!

    Took me under a minute and the bar was gone… forever… truly grateful.

    Sally :) x

  41. Corey Freeman says:

    Thanks to this I have one less plugin bloating my site. Woo!

  42. Delton Childs says:

    This is an awesome post. short, to the point and contained a useful snippet! Thank you so much!

    I’m using the S2Member plugin also, I was very concerned about compatibility issues with plugin based solutions because of the various s2Membership Levels. This solutions is working wonderfully for me.

    Thanks Again!

  43. James Davis says:

    Hi Guys,

    Just found this bit of code and it worked perfect for my site…

    Thanks so much



    AKA The Fitness Blogger

  44. glueckpress says:

    Nice. For Superadmins in a Multisite install it would read like if(!current_user_can(‘manage_network’)) //etc.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.