Categories
WordPress

Show Admin Bar to Administrators only in WordPress

If you are using WordPress than you might be quite aware of the thing called Admin Bar. It is the bar that apears at the top of your WordPress site when you are logged in. Today I will tell you how to show this bar to admins only.

Why only admins?

  • If you have a multi author blog, then admin bar may have a bad impact
  • If you add any thing to admin bar, that is in relation to admin control you need to keep it secure
  • Admin bar sometimes messes up the layout so better remove it for non admins

How to do it?

Put this code in your activated theme's functions.php file & You are done

 

<?php
 
// Snippet code goes here!
if (!current_user_can('administrator')) :
  show_admin_bar(false);
endif;
 
?>
If hope you will Enjoy this snippet.
 

 

 

By Freakify Editorial

The post was written by Freakify Team.

This blog used to be managed by Ahmad Awais before it was acquired.

I have had been designing web pages since the early days of tables & spacers. And No – I’ve never used the scrolling marquee with Comic Sans fonts . Well, I am an Entrepreneur who left his orthodox path of Electrical Eng after graduation to become a UX Engineer/Marketer & a Motivational Speaker. Read more about me at AhmadAwais.com

2 replies on “Show Admin Bar to Administrators only in WordPress”

Hello Ahmad,
I like your blog’s post, every time i get new things to learn from your blog.

The above information is really helpful and i’ll surly try, if i get trouble then i’ll ask you.

Thanks for sharing with us. :)

Comments are closed.