Ready to get started?Download WordPress


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

  1. roiabrazaldo
    Posted 6 months 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 6 months 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 6 months 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');


You must log in to post.

About this Topic