WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the following code to hide the admin toolbar in the front end:
add_filter( 'show_admin_bar', '__return_false' );

But how do I hide this option in wp-admin?

enter image description here

share|improve this question
up vote 4 down vote accepted

Here's one way to hide it with CSS:

add_action( 'personal_options', function( $profileuser )
{
    ?><style>.show-admin-bar{ display: none;}</style><?php
} );

or rather place it within the <head>...</head> with:

add_action( 'admin_print_styles-user-edit.php', 'wpse_hide_admin_bar_settings' );
add_action( 'admin_print_styles-profile.php',   'wpse_hide_admin_bar_settings' );

function wpse_hide_admin_bar_settings()
{
    ?><style>.show-admin-bar{ display: none;}</style><?php
} 

You could perhaps add your own wpse_hide_admin_bar_settings filter if you need more control:

function wpse_hide_admin_bar_settings()
{
    if( (bool) apply_filters( 'wpse_hide_admin_bar_settings', false ) )
        echo '<style>.show-admin-bar{ display: none;}</style>';
} 

and then turn it off/on with:

add_filter( 'wpse_hide_admin_bar_settings', '__return_false' ); // show it
add_filter( 'wpse_hide_admin_bar_settings', '__return_true' );  // hide it
share|improve this answer
    
Thanks, that will work. Although one would think that when you disable this in the frontend, this option would at least be disabled backend. – Steven Feb 26 at 9:19
    
If I understand your comment, Steven: a) The "Show Toolbar" option is something a user might want to enable some times and disable other times. If unchecking the option in the dashboard removed it from the dashboard, there's no way to re-enable it. b) Quite curious: why do you want to remove this feature? – Jeff Cohan Feb 26 at 14:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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