Change WordPress user roles and capabilities Forums How to or FAQ How to block/hide items from the top bar of wordpress?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #3316
    pazazta
    Participant

    I have in the top bar of items that I want to remove such as “Yoast SEO”.
    I want to remove it only from the top and keep it on the regular menu

    #3318
    Vladimir
    Keymaster

    In general, top admin menu bar menu is blocked automatically if its correspondent main admin menu item was blocked.

    In order to block “Yoas SEO” just at top admin menu bar use this code:

    
    add_action('wp_before_admin_bar_render', 'block_top_wp_seo');
    
    function block_top_wp_seo() {
        global $wp_admin_bar;
        
        if (current_user_can('administrator')) {
            return;
        }
        
        $wp_admin_bar->remove_menu('wpseo-menu');
    
    }
    
    

    Insert into the active theme functions.php file for the single site or setup as a “must use” plugin to aplly it globally to all sites.

    https://codex.wordpress.org/Must_Use_Plugins

    #3320
    pazazta
    Participant

    Great thank you!

    #8175
    bsahin
    Participant

    How about to opposite way?
    Administrator can see some items in top bar.
    But shop managers can’t see them (it is not blocked from admin menu)

    So how to make sure shop managers can see some plugins’ items in top bar?

    #8178
    Vladimir
    Keymaster

    Top admin menu bar items are the duplicates of the similar items from the main left side admin menu. So if use has access to the admin menu item, then he should have access to the similar item at the top admin menu bar.
    If user does not have access to the main admin menu item, then you need to grant him such access, adding to a role a capability, which has administrator, but does not have this role.

    #8179
    bsahin
    Participant

    Hi Vladimir,
    Thanks for quick reply.
    I have few plugins, which shop managers can see in left menu but can’t see on top admin menu bar.
    May it be related with plugins?
    Rank math
    Pressable cache manager
    Flyingproxy

    #8289
    bsahin
    Participant

    Pressable cache management plugin also have same issue.
    Admin can access both left and top menus.
    Shop manager can access only left menu.
    It is related with plugin itself? Where they should update?

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.