14 Feb 2017

How to Disable Admin Bar in WordPress Except for Administrators

Wouldn't it be great if you knew how to disable the admin bar in WordPress if you intended to run a membership website? That would be awesome, wouldn't it? Yeah because building a membership website can be pretty expensive but you don't have to spend any huge amount of money to get a membership website for yourself if you know what you are doing and I'm going to show you how to do something cool.

How To Disable Admin Bar In WordPress Except for Administrators.
Not that long ago I wanted to disable the admin bar for some certain users of one of my clients website and I figured out a way of doing that and that's what I'm about to show you now, I appreciate it if you'd let me know in the comments that this article was helpful to you.

In order to disable admin bar in WordPress for all users except for administrators, all you need to do is copy and paste the below code into your functions.php file.

[php]
add_action('after_setup_theme', 'remove_admin_bar');

function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
[/php]

How to Disable Admin Bar for All Users

Also, if you wish to disable admin bar in WordPress for all users simple copy and paste the below code into your functions.php file

[php]
/* Disable WordPress Admin Bar for all users but admins. */
show_admin_bar(false);
[/php]

I want to give you other great articles on how to disable admin bar in WordPress. Check the below links out:

I hope this article helped you and if you liked this article, then please subscribe to my YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook

Leave a Reply

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