• Resolved dev grl

    (@siqve006)


    I already have this code that is in my functions to hide the toolbar from any logged in user other than admins, but when I created a new user role and gave it admin capability, the toolbar still remains hidden when logged in as that user. What can I adjust in my functions code to include the user titled ‘testuser’ as also able to see the admin toolbar?

    add_action(‘after_setup_theme’, ‘remove_admin_bar’);

    function remove_admin_bar() {
    if (!current_user_can(‘administrator’) && !is_admin()) {
    show_admin_bar(false);
    }
    }

    https://ww.wp.xz.cn/plugins/advanced-access-manager/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi dev grl,

    Thank you for your question. Based on your example, you are relying on capabilities which is the best way to go.

    Problem with utilizing after_setup_theme hook is that it is executed before init hook (which is used to initialize AAM plugin).

    I had some time and added a the ability to show/hide admin bar with AAM. Simply create a new capability show_admin_bar and check/uncheck it for your role. This will show/hide admin bar.

    Download and install AAM development version from here.

    Feel free to ask more questions if any.

    Regards,
    Vasyl

    Thread Starter dev grl

    (@siqve006)

    Thanks, is this feature being added to the plugin or is this a specialized plugin version? I just want to make sure I don’t lose anything in the updates. Otherwise if you could suggest another function that would work better I can just change what I’ve already used in my functions file.

    Hi dev grl,

    It is going to be included in our next update so no worries about losing it. Go ahead and use it.

    Let us know if something is not working as expected.
    Thank you for your interest in AAM.
    Vasyl

    Thread Starter dev grl

    (@siqve006)

    So I can delete the old and just reinstall this without losing data? Last time I did an update on your plugin it caused a fatal error so I was timid this time.

    Thread Starter dev grl

    (@siqve006)

    Is this correct?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘show/hide admin bar for certain role’ is closed to new replies.