Where can I define which menu entries in the user navigation will be shown to which role?

The “User” navigation menu is set to display some elements only to users with a certain role:


For example the “Administration” element is only shown to users with that role. Where can I change that behaviour?

We use a generic reader user account and I don’t want the several people who are sharing this account to change the password so my idea was not to display the “Dashboard” and “View Profile”. That way only really elaborate users who know the URL would be able to get to that point.

Any ideas?

Thank you very much!

Hi @D_Schroeder_Micheel,

This is done by code, here https://github.com/pkp/pkp-lib/blob/master/classes/services/PKPNavigationMenuService.inc.php#L144 for the existing default menu item “Administration”. You could change the code there to your desired behaviour, but I strongly suggest that, for your purposes, you use the the hook defined here https://github.com/pkp/pkp-lib/blob/master/classes/services/PKPNavigationMenuService.inc.php#L327, maybe within a custom plugin in order to change the functionality, but not change the base code of your installation.

In general, the setIsDisplayed function of the NavigationMenuItem is responsible for displaying or not each NMI. By passing false to that function for any NMI, that causes the NMI to not be displayed. In your case, I think that you could just check if the user has the role reader (or check the username of the logged-in user), and pass the appropriate parameter to the NMI that you are interested in (for example NMI_TYPE_USER_PROFILE and NMI_TYPE_USER_DASHBOARD).


1 Like