Remove Admin Bar For Subscribers

Avatar of Chris Coyier
Chris Coyier on

You might want open registration on your WordPress site so that (for one small example) people can log in and leave comments on things without needing to type their name/url/email every time. But these users probably don’t need to see the whole top admin bar as there likely isn’t much use in it for them. Although do be sure to provide a link to edit their profile and log out.

This would be for your functions.php file or functionality plugin:

add_action('set_current_user', 'cc_hide_admin_bar');
function cc_hide_admin_bar() {
  if (!current_user_can('edit_posts')) {
    show_admin_bar(false);
  }
}