Disable WordPress 3.1 admin bar for all users except admin

WordPress admin bar is a new feature of wordpress 3.1. For some customised wordpress  CMS like our ASK Binbert have to disable navigation to default wp-admin for all users, if the Admin bar is showing top of the site it will give a temptation to go to dashboard. but site have their own dashboard for the users. In these situations we have to disable wordpress admin bar.  There is an option to change this settings in the user profile page. But it is not practical to apply for all users profile. I found to solutions to remove admin bar from site view.

image

Disable wordpress  3.1 Admin bar using plugin, ( All users including admin )

Appling a plugin is the easiest way to disable admin bar, Download this plugin from  http://wordpress.org/extend/plugins/disable-admin-bar/ and activate it. By activating the plugin admin bar will be disappear from the site.

Disable Admin bar by editing functions.php  ( All users including admin )

Find and append the following lines to you functions.php which is located in your theme directory.

function my_function_admin_bar(){
return false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');

Code to disable admin bar for all users other than administrators

function my_function_admin_bar($content) {
return ( current_user_can("administrator") ) ? $content : false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');

About Albin Sebastian

I am a Technology Blogger, System Administrator by profession and webmaster by passion. Technology blogger, Active in Online and offline tech communities.

Check Also

MySql replication

Disaster recovery of Mysql using DRBD and Heartbeat

Disaster recovery (DR) is the process, policies and procedures that are related to preparing for …

Comments