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

How to Disable WordPress Admin Bar for All Users Except Administrators

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
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()) {
  show_admin_bar(false);
}
}

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. */
  show_admin_bar(false);

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 »

Comments

  1. Louis says:

    It works just perfect!
    Easy and functional.
    Thank u!

  2. lucas says:

    Yo your code line has ruined both of my sites I cannot acces the wp-admin at all I get a fatal error message.. how can I fix this please :(

  3. Peters A P says:

    I did what was mentioned on the link you send me.

    Now the entire site is gone

    I cannot see anything, please check for yourself and see.

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.