How To Stop WordPress Admin Bar From Loading For All Non Administrators

Home » WordPress Tutorials » How To Stop WordPress Admin Bar From Loading For All Non Administrators
  • disable-the-wordpress-admin-bar

How To Stop WordPress Admin Bar From Loading For All Non Administrators

The WordPress admin bar is a useful feature for when you’re managing your website. I tend to only find it useful, when I am working on the website. For example, most plugins use it for common features, such as a caching plugin using it to clear the cache.

If I am writing a post or just clicking around on a website as a user, the admin bar is clunky and annoying. Not only that but it slows down the website for something most users do not use.

When browsing a website as a user, I have never found the need to check the admin bar. No matter if I was logged in or not, simply because it is not a useful feature for me.

As a developer, the WordPress admin bar is great bridge between the admin panel and the front-end. For example, I can clear the cache with Autoptimize, use server-side caching, or access the customizer if needed.

But some website owners like to disable the WordPress admin bar for non-administrators. The following code will disable it.

This code can be added to the following places:

  • functions.php file
  • site-specific plugin

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

That’s all there is to it! Now any non-administrators will not have the WordPress admin bar appear when logged in. Administrators will still continue to see the admin bar.

By | 2018-02-28T18:41:44+00:00 February 28th, 2018|Categories: WordPress Tutorials|Tags: |0 Comments

About the Author:

Scott Hartley is a WordPress Developer who focuses on website performance optimization, SEO, and security. He can't tell you what a color wheel is but he knows the intricacies of making a website load quickly.

Leave A Comment