Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Disable WordPress Admin Bar for All Users Except Administrators

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Do you want to disable the WordPress admin bar for all users except administrators?

By default, you can easily disable the WordPress admin bar for individual users. However, this can take time if you have lots of registered users on your site.

In this article, we will show you how to easily disable the WordPress admin bar for all users except administrators.

How to disable WordPress Admin Bar for All Users except administrators

What Is the WordPress Admin Bar?

By default, WordPress shows an admin bar at the top of the screen for all logged-in users. When you are logged into your account, you can see this toolbar in the WordPress admin area and all other pages.

The WordPress admin bar

The WordPress admin toolbar has useful shortcuts to different backend areas of WordPress, and these shortcuts change based on a user’s role and permissions in WordPress.

However, the admin bar can be distracting when you are looking at the front end of your website.

It may also affect your website’s design and user experience. This can be a problem if you are building or managing a WordPress site for a third party, as it stops them from seeing what their website really looks like.

Luckily, there are multiple ways to disable the admin bar for all users except administrators. Simply use the quick links below to jump to the method you want to use:

Video Tutorial

Subscribe to WPBeginner

If you prefer written instructions, then just keep reading.

Method 1: Disable the WordPress Admin Bar for Individual Users

You can disable the admin bar for specific users by simply editing their user profile. This is a quick and easy method if you just need to remove the bar for a small number of people. However, if you run a membership site with a lot of users, then we recommend choosing a different method.

To remove the admin bar manually, simply go to the Users » All Users page in the WordPress admin dashboard. Then hover your mouse over the user who doesn’t need the admin bar, and click on ‘Edit’ when it appears.

How to edit a user's profile in WordPress

This will bring open that user’s profile.

From here, uncheck the box next to the ‘Show toolbar when viewing site’ option.

How to hide the admin toolbar for non-admin users

After that, scroll to the bottom of the screen and click on ‘Update User’ to save your changes. This will disable the admin bar for that specific person only.

To hide the toolbar for more users, simply follow the same process described above.

Method 2: Disable Admin Bar for All Users Except Admins (Recommended)

If you need to hide the admin bar for lots of different people, then changing each user’s settings manually would take a lot of time and effort.

For that reason, we recommend disabling the admin bar by adding code to the functions.php file, which is a WordPress theme file. If you haven’t done this before, then check out our guide on how to copy and paste code snippets in WordPress.

Some guides will tell you to edit the theme files manually, but this can cause common WordPress errors and may even completely break your website.

For that reason, we recommend using WPCode. It is the best code snippet plugin and makes it easy to add custom code in WordPress without putting your site at risk.

First, you will need to install and activate the free WPCode plugin. For more information, see our step-by-step guide on how to install a WordPress plugin.

Once the plugin is activated, go to Code Snippets » Add Snippet.

Hiding the admin toolbar using WPCode

Here, you will see all the pre-made snippets you can add to your site. This includes a snippet that allows you to completely disable comments, upload file types that WordPress doesn’t usually support, disable attachment pages, and much more.

On the next screen, you need to hover your mouse over the ‘Add Your Custom Code (New Snippet)’ option and click the ‘Use snippet’ button when it appears.

Adding custom code to your WordPress website with WPCode

On the next screen, type in a title for the code snippet. This is just for your reference, so you can use anything you want.

Then, open the ‘Code Type’ dropdown and choose ‘PHP Snippet’.

Adding a PHP snippet to WordPress using WPCode

With that done, simply paste the following code to the editor:

add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
  show_admin_bar(false);
}
}

This code identifies any non-admin users who are not currently looking at the admin dashboard. For these users, it disables the WordPress admin bar.

After that, scroll down the page to the ‘Insertion’ section. Here, you can keep the default’ Auto Insert’ method to make sure the code runs everywhere.

Automatically inserting code into a WordPress website

Finally, scroll to the top of the screen and click on the ‘Inactive’ slider so that it shows ‘Active.’

Then, just click the ‘Save Snippet’ or ‘Update’ button to make the code snippet live.

Publishing a custom code snippet to WordPress

That’s it! Just remember to check your WordPress website to make sure everything is working fine.

Method 3: Disable WordPress Admin Bar for All Users Except Admins (No Code Required)

If you don’t want to add code to your website, then you can hide the admin bar using a plugin. Hide Admin Bar Based on User Roles lets you remove the toolbar based on different user roles, so this is a good choice if you want to disable the bar for all members, WooCommerce customers, or some other user role.

First, you need to install and activate the Hide Admin Bar Based on User Roles plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, you need to go to the Settings » Hide Admin Bar Settings page. From here, check the boxes next to the user roles where you want to disable the admin bar.

Hiding the admin toolbar for specific user roles

With that done, simply click on ‘Save Changes’ to store your settings.

Method 4: Disable Admin Bar for All Users (Including Admins)

Do you want to disable the admin bar for all users, including site admins?

You can do this by adding some code that disables the admin bar for everyone who is viewing your site’s public pages. This means the admin bar will only appear when you are in the WordPress dashboard area.

To make things simple, WPCode has the exact code snippet you need in its built-in Snippet Library. Simply go to Code Snippets » Library.

The WPCode code snippet plugin for WordPress

Here, search for ‘Disable The WP Admin Bar’.

When the right snippet shows up, just click on its ‘Use Snippet’ button.

The ready-made Disable The WP Admin Bar code snippet

The plugin will automatically add the code to your site, give the code a descriptive title, choose the correct insertion method, and even add tags to help you identify the snippet.

Here’s what the code looks like:

/* Disable WordPress Admin Bar for all users */
add_filter( 'show_admin_bar', '__return_false' );

Now, all you need to do is toggle the switch from ‘Inactive’ to ‘Active’ and then click on ‘Update’.

Adding custom code to WordPress

Now, if you visit your website’s front end while logged into your WordPress account, the admin bar will disappear.

We hope this article helped you learn how to disable the WordPress admin bar for all users except administrators. You may also want to see our ultimate WordPress security guide and our comparison of the best WordPress page builders for creating custom page layouts without any code.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

162 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Moinuddin Waheed says

    This is very needed to hide the admin bar to all the user’s except the administrator.
    I have thought of doing this multiple times over specially when I was running news website and I had many authors and contributors.
    Showing them admin bar is not only unnecessary but annoying too.
    Really appreciate for the steps to get rid of this admin bar and keep it for only the administrator.

  3. Amos Showole says

    Wow… This is great, you solved an issue I faced with on one of my WordPress website that BuddyPress was installed on….

Leave a Reply to Vic Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WPBeginner Assistant
How can I help you?

By chatting, you consent to this chat being stored according to our privacy policy and your email will be added to receive weekly WordPress tutorials from WPBeginner.