How to Disable WordPress Admin Bar for All Users Except Administrators

The WordPress admin bar is a toolbar that appears at the top of the screen for all logged-in users. It provides quick access to various features and settings of WordPress, such as dashboard, themes, widgets, menus, customize, new page, edit post, etc.

However, you may want to disable the WordPress admin bar for some or all of your users for various reasons. For instance, you may want to:

  • Improve the front-end design and user experience of your website
  • Prevent non-admin users from accessing the backend of your website
  • Reduce the load on your server and improve performance
  • Simplify the user interface and avoid confusion
showing site with admin bar

In this blog post, we will show you how to disable WordPress admin bar for all users except administrators using different methods. You can choose the method that suits your needs and preferences.

Method 1: Disable WordPress Admin Bar for Specific Users Manually

The easiest way to disable WordPress admin bar for specific users is to edit their user profile settings. This method is suitable if you have a small number of users and you want to disable the admin bar for some of them individually.

To do this, follow these steps:

  1. Go to Users > All Users in your WordPress dashboard.
  2. Hover over the user name of the user you want to disable the admin bar for and click on Edit.
  3. Scroll down to the Toolbar section and uncheck the box next to Show Toolbar when viewing site.
  4. Click on Update User to save your changes.

Repeat these steps for any other user you want to disable the admin bar for.

Method 2: Disable WordPress Admin Bar for All Users Except Administrators Using Code

If you want to disable WordPress admin bar for all users except administrators, you can use a code snippet to do so. This method is recommended if you are comfortable with editing your theme files or using a site-specific plugin.

To use this method, follow these steps:

  1. Go to Appearance > Theme Editor in your WordPress dashboard.
  2. Select the functions.php file of your active theme from the right sidebar.
  3. Scroll down to the end of the file and paste the following code snippet:
// Disable WordPress Admin Bar for all users except administrators
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
  if (!current_user_can('administrator') && !is_admin()) {
    show_admin_bar(false);
  }
}
  1. Click on Update File to save your changes.

This code snippet will check if the current user is an administrator or not. If not, it will hide the admin bar from the front-end of your website.

Method 3: Disable WordPress Admin Bar for All Users Except Administrators Using a Plugin

Another way to disable WordPress admin bar for all users except administrators is to use a plugin. This method is suitable if you prefer not to edit any code or files on your website.

There are several plugins that can help you with this task, but we will use Hide Admin Bar on User Roles as an example. This plugin allows you to hide the admin bar for selected user roles with a few clicks.

To use this plugin, follow these steps:

  1. Install and activate the Hide Admin Bar on User Roles plugin from the WordPress plugin repository.
  2. Go to Settings > Hide Admin Bar Settings in your WordPress dashboard.
  3. Select Hide Admin Bar for Selected User Roles option.
  4. Check all the user roles except Administrator from the list.
  5. Click on Save Changes to apply your settings.

This plugin will hide the admin bar for all users except administrators based on their user roles.

Conclusion

In this blog post, we have shown you how to disable WordPress admin bar for all users except administrators using different methods. You can choose the method that works best for you and your website.

Disabling WordPress admin bar can help you improve the design and user experience of your website, prevent unauthorized access to your backend, reduce server load and improve performance, and simplify the user interface.

We hope you found this blog post helpful and informative. If you have any questions or feedback, please feel free to leave a comment below.

Leave a Comment

Your email address will not be published. Required fields are marked *