Monday, November 30, 2020
Home Blogging How to Disable WordPress Admin Bar for All Users Except Administrators

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 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

How to Signup for Godaddy Affiliate Program & Start Making Money

GoDaddy is likely one of the well-liked model names out there of area and web-hosting. They are well-liked for a numerous cause, and so they...

How To Start Selling Website on Flippa: A Beginner’s Guide To Success

If you may have been working on-line for lengthy and into Website flipping, Flippa is one identify that you need to have heard of. Flippa is a...

How to Fix Your Connection is Not Private Error (Site Owners Guide)

Are you seeing ‘Your connection is not private’ error in your WordPress web site? This is the error message you’ll see on Google Chrome. The...

How to Fix the WordPress White Page of Death (Step by Step)

The WordPress white page of dying is one of the most widespread WordPress errors. It can also be one of the most irritating ones as...

Recent Comments