How To Hide WordPress Admin Bar For Everyone Without Any Plugin?

Have joined any blogging community where you get the login credentials but you won’t able to see the admin bar?

It’s because, at most of the membership websites, people hide WordPress admin bar for everyone except administrator.

Just a couple of days ago, someone raised a question how could he disable the admin bar for his website’s users.

Well, WordPress is an interesting platform and today, you won’t use any plugin from its repository.

The first choice of many users is a plugin.

But here I am going to provide you two types of codes.

Open the functions.php File of Your WordPress Theme.

As you all know, the functions.php file is one of the most important files of a WordPress theme.

You can open it from the cPanel or use your admin panel.

Go to cPanel>>file manager>>wp-content>>themes>>theme name>>functions.php file.

It seems quite a long process to the newbies. So I recommend you to open it from your WordPress admin panel.

Just go to Appearance>>Editor>>functions.php file.

But sometimes when you are not able to login to your WordPress dashboard, cPanel is the only option at that time.

The code to disable the admin bar for everyone is here.

show_admin_bar(false);

Copy and paste this code to the file and save it.

The WordPress admin bar will not be visible to anyone.

But what if you want to remain it visible for the administrator.

Well, there is another code for that. You have to create a function and an IF statement.

Let me provide you the code.

function hide_admin_bar() {

if (current_user_can(‘administrator’) && !is_admin()) {

show_admin_bar(false);

} }

add_action(‘after_setup_theme’, ‘hide_admin_bar’);

Save the file and try to login as some other user and you won’t see the admin bar.

But if you try to login as an administrator, you will have a nice looking admin bar. It’s only for you, no one else can see it.

You have successfully disabled the admin bar for all of your users.

The choice is yours whether you want to keep it visible for the administrator or not.

Would You Keep It Showing To Everyone or Just The Admin?

It’s the matter of choice.

But still, I would recommend to keep it visible it for the admin. As you are going to handle the website and it’s important to have a look to the bar.

What’s your choice? Which code are you going to use?

Would you hide WordPress admin bar for everyone or just for your users? The matter of fact is that you can alter the code shown above.

With a little of knowledge about WordPress codes, you can generate your own function.

Connect with us on Twitter, LinkedIn, and Facebook.

by Ravi Chahar

A WordPress Professional and the LinkedIn Influencer. A coder by passion and a blogger by choice. WordPress theme development is his forte. He is your WordPress guy who will teach you how to solve WordPress errors, WordPress security issues, design issues and what not.

Get Free Updates Into Your Inbox

Learn Everything Just Like I Did

SUBSCRIBE

Leave a Reply

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