hide wp admin bar for subscribers

Solutions on MaxInterview for hide wp admin bar for subscribers by the best coders in the world

showing results for - "hide wp admin bar for subscribers"
Simón
08 Feb 2016
1add_action('after_setup_theme', 'remove_admin_bar');
2 
3function remove_admin_bar() {
4if (!current_user_can('administrator') && !is_admin()) {
5  show_admin_bar(false);
6}
7}
8
Vanessa
29 Jul 2020
1/* 
2* Add this to the bottom of your functions.php file to hide the wp admin
3* bar for all users except those whom can edit posts.
4*/
5
6add_action('set_current_user', 'cc_hide_admin_bar');
7function cc_hide_admin_bar() {
8  if (!current_user_can('edit_posts')) {
9    show_admin_bar(false);
10  }
11}