Skip to content

Instantly share code, notes, and snippets.

@menslow
Created April 16, 2012 18:20
Show Gist options
  • Save menslow/2400487 to your computer and use it in GitHub Desktop.
Save menslow/2400487 to your computer and use it in GitHub Desktop.
WordPress: Add filter to control which users see the admin bar.
/**
* mm_show_admin_bar function.
* Filter to control which users see the admin bar.
* @access public
* @return false or true if user is admin.
*/
function mm_show_admin_bar() {
if (current_user_can('administrator')) {
return true;
} else {
return false;
}
}
// Hide admin bar
add_filter( 'show_admin_bar', 'mm_show_admin_bar' );
/**
* mm_show_admin_bar function.
* Filter to control which users see the admin bar.
* @access public
* @return false or true if user is admin.
*/
function mm_show_admin_bar() {
if(is_admin())
{
return true;
}
return false;
}
// Hide admin bar
add_filter( 'show_admin_bar', 'mm_show_admin_bar' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment