• Resolved Marc_J

    (@marc_j)


    Hi,

    your documentation states that you can hide the admin bar for users by using the custom show_admin_bar capability, but unfortunately it doesn’t work. I’m referring to the following text:

    “If you are looking to complete hide admin toolbar on the frontend for any roles or individual users, you can create a custom capability show_admin_bar and make sure that it is not checked for desired role or user.”

    Best,
    Marc

Viewing 3 replies - 1 through 3 (of 3 total)
  • Noel

    (@noelalvarez)

    hi @marc_j,

    Please check this more details article on how to hide admin bar –> https://aamplugin.com/article/how-to-hide-wordpress-admin-bar

    Hope this would help you better.

    Thread Starter Marc_J

    (@marc_j)

    Hi @noelalvarez,

    thank you for the link, but I actually tried it according to that article.

    After digging into your code the plugin seems to work fine, but the show_admin_bar function won’t work in my install. A quick web search revealed that there may be problems with it.

    See https://codex.wordpress.org/Function_Reference/show_admin_bar for example: “With newer version of WordPress you may need to use the following which will leave the Toolbar available in the Dashboard but hide it on all front facing pages.

    The following additional code (which could replace your use of the show_admin_bar function) works for me now:

    if ( ! current_user_can( ‘show_admin_bar’ ) ) {
    add_filter( ‘show_admin_bar’, ‘__return_false’, PHP_INT_MAX );
    }

    Best,
    Marc

    Plugin Author AAM Plugin

    (@vasyltech)

    Hi @marc_j,

    Thank you for the research . Your solution makes complete sense when there is some other functionality that manages toolbar visibility.

    Honestly it is also better solution than what I’ve originally implemented by using show_admin_bar core function.

    I’m adjusting AAM code based on your recommendation.

    Thank you,
    Vasyl

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide admin bar’ is closed to new replies.