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?


1 Answer 1

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');
add_action('init', 'disable_admin_bar_for_subscribers', 9);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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