How to remove "Show Toolbar when viewing site" option in User Profile? (4 posts)

  1. roiabrazaldo
    Posted 2 years ago #

    Hi guys! I manage to remove the toolbar if the user is not administrator by using this :

    if ( ! current_user_can( 'manage_options' ) ) {
    show_admin_bar( false );

    but still, when I go to the User Profile, I still see the
    "Show Toolbar when viewing site" Option, which is logically wrong.
    How can I remove that option?

  2. RossMitchell
    Posted 2 years ago #

    This solution is not very subtle and could still be subverted by a motivated hacker/user, there has to be an better way to do this:
    Add this to yout style.css:
    tr.show-admin-bar { display:none; }
    The issue is that the control is only hidden.
    Maybe there is a way to filter the <tr>...</tr> that encloses the tick box out of the page ? Anyone ?

  3. respectyoda
    Posted 2 years ago #

    Make sure you are using a child theme first. You can use this following code in functions.php:

    if ( ! current_user_can('manage_options') ) {
         add_filter('show_admin_bar', '__return_false');
  4. mischa.mole
    Posted 1 year ago #


    On my site, users _need_ to see the admin bar, otherwise a lot of stuff isnt working. As the user above, I want to remove the option "Show Toolbar when viewing site" from the profile page, so nobody can accidentally unselect it. Is this somehow possible?


Topic Closed

This topic has been closed to new replies.

About this Topic