[Resolved] Slide-out menu icon visibility

Home Forums Support [Resolved] Slide-out menu icon visibility

Home Forums Support Slide-out menu icon visibility

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #343751
    Frank

    Greetings good folks,

    I want to use the slideout menu for collaborators only. This makes it easy for me to work on pages without them being visible to the general public.
    So, could you write me a little PHP snippet like you did for the shopping cart?
    I want the hamburger menu icon (slideout menu trigger) to be visible only to logged-in users of WP role “collaborator”.

    THX so much in advance.

    #343827
    Tom
    Lead Developer
    Lead Developer

    Same sort of thing:

    add_action( 'after_setup_theme', 'tu_slideout_icon_collab' );
    function tu_slideout_icon_collab() {
        remove_filter( 'wp_nav_menu_items','generate_menu_plus_slidebar_icon', 10, 2 );
    
        if ( current_user_can( 'contributor' ) ) {
            add_filter( 'wp_nav_menu_items','generate_menu_plus_slidebar_icon', 10, 2 );
        }
    }

    I put contributor as collaborator isn’t a role: https://codex.wordpress.org/Roles_and_Capabilities

    #344292
    Frank

    THX a lot!
    Sure did the trick.

    #344308
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

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