• Good day,

    This is a good and useful plugin, I use it and it is working well for me.

    My question, would it be possible to change or add a code that makes it control the whole menu without going into each item separately?

    My application is that I want to create many menus complete with their items and that every menu will be assigned to a specific role.

    Your help is much appreciated.

    Thanks,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    Hi,

    That’s an interesting idea, but it’s not a feature that I am looking to add right now. You can always add that kind of conditional logic into your header.php file.

    Cheers,
    -kathy

    Thread Starter SolutionsDEV

    (@solutionsdev)

    Hi Cathy,

    Thanks a lot for this suggestion. Do you have a code that I could use in the header or as a function?

    Thanks a lot.

    Plugin Author HelgaTheViking

    (@helgatheviking)

    Assuming your logic is based on WP user roles/capabilities you’d use current_user_can() and replace your generic menu call, ex:

    
    wp_nav_menu('primary');
    

    with something like:

    
    if ( current_user_can( 'manage_options' ) ) {
       wp_nav_menu('primary-admin');
    } else {
       wp_nav_menu('primary');
    }
    

    where users who can manage options are generally Admins. You can use roles in current_user_can($role) as that’s what I use in NMR because it’s easier to read, but technically it’s more precise to use capabilities.

    Also this assumes that you have two menus locations registered, primary-admin a menu for admins only and primary your regular menu.

    I hope that helps.

    Thread Starter SolutionsDEV

    (@solutionsdev)

    Thanks a lot Cathy, this should help a lot, although I intend to use it based on roles, for example student role will see student-menu only, teacher role will see teacher-menu only, while parent role will see parent-menu and so on.

    I will try to make changes and try the code in the next few days.

    Thanks a lot for your continuous help.

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

The topic ‘Whole Menu Roles’ is closed to new replies.