How to Disable WordPress Admin Bar for All Users Except Administrators

Lately whereas engaged on a membership web site, we needed to create a number of degree of customers. We didn’t need the customers to have entry to the WP-Admin panel as a result of it was not personalized for his or her expertise. Somewhat we had put all the things obligatory (resembling edit profile web page), consumer dashboard and many others, on the front-end. Whereas S2 Membership Plugin allowed for us to disable wp-admin entry for all customers aside from admins, there was no choice to disable the admin bar by default. On this article, we’ll present you the right way to disable WordPress Administrators bar for all customers aside from Directors.

Disable Admin Bar for All Customers Apart from Directors

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

1
2
3
4
5
6
7
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 Customers

If you wish to disable it for all customers, then merely put use this code in your theme’s features.php file or your site-specific plugin.

1
2
/* Disable WordPress Admin Bar for all users but admins. */
 show_admin_bar(false);

 

You May Also Like : Add a Custom Class in WordPress Menu Item using Conditional Statements

If you liked this article, make sure to hit the bell for getting our latest updates and share this article with your friends in every social media platforms.

1 thought on “How to Disable WordPress Admin Bar for All Users Except Administrators”

  1. Pingback: How to Properly Change Your WordPress Username (Step by Step)

Leave a Comment

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