Hide Admin Bar without Plugin
Hide Admin Bar without Plugin
in

How to Hide Admin Bar without Plugin in just 5 minutes?

WordPress is one of the best CMS (Content Management System), and they claiming more than 23% of total websites are running on their platform. Due to its popularity and simplicity, everyone wants to shift their web-applications on WordPress, which leads to the security and other wp error issues that the users face. One of them is to hide the admin bar from the users.

Hide Admin Bar without Plugin
Hide admin bar

To hide admin bar we have to simple methods:-

  1. by using a Plugin
  2. by adding some code to the wp-files

But today, we will learn the 2nd method for the same, and I highly recommend this method because using too many plugins will kill your page speed, which hurts your revenue stream.

You may also read this: Fix All WordPress errors through five working methods

So are you ready to code? Let’s start!

Hide Admin Bar for All Users Except for Administrators

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

// hide admin
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);

Disable admin bar for excepted users

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

//hide admin bar
add_action('after_setup_theme', 'remove_admin_bar');
 
function remove_admin_bar() {
if (!current_user_can('administrator', 'editor') && !is_admin()) {
  show_admin_bar(false);
}
}

You may also read this: How to speed up your wordpress website and boost your traffic

Last words

If I left some other important methods for doing the same, please leave in the comment section and don’t forget to give feedback, this will motivate me for writing more quality articles for you.

Thank you!

Comments

Leave a Reply

4 Pings & Trackbacks

  1. Pingback:

  2. Pingback:

  3. Pingback:

  4. Pingback:

Leave a Reply

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

Loading…

0

What do you think?

-1 points
Upvote Downvote
programming

Introduction to Programming – Day1

10 hidden Google tricks we bet you didn’t know!

10 amazing Google tricks