1

Maybe this is a stupid question.

When a user logins to my Wordpress site with the Subscriber role, they have the WP Admin Bar appearing at the top of the page. The user can go into their dashboard and turn this off themselves. But how can I turn this off by default for all existing and new users?

5
function disable_admin_bar_for_subscribers(){
    if ( is_user_logged_in() ):
        global $current_user;
        if( !empty( $current_user->caps['subscriber'] ) ):
            add_filter('show_admin_bar', '__return_false');
        endif;
    endif;
}
add_action('init', 'disable_admin_bar_for_subscribers', 9);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.