WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. roiabrazaldo
    Member
    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
    Member
    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
    Member
    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');
    }

Reply

You must log in to post.

About this Topic

Tags