User menu privileges

Hello!

At the moment when the user access the project is enabled to use some parts of the menu.
image
so if not enable appear the prohibited icon on rollover

I did it enabling those parts from numbers in the user notes with:

  if notes:
	            try:
	           
	                parts = notes.split(";")
	                for part in parts:
	                    if part.startswith("zones:"):
	                    
	                        zone_numbers = part.split(":")[1]
	                        enabled_zones = set(zone_numbers.split(","))
	                    elif part.startswith("access:"):
	                        # Get the access value and determine enabled items
	                        access_numbers = part.split(":")[1]
	                      
	                        enabled_access = [int(digit) for digit in access_numbers]

I would like to know if is possible to hide those parts of the menu instead, so they don´t appear to the user with no privileges.

Thanks and happy Christmas,
Alejandro

If you build your menu's items by script

I can see three easy choices:

  1. Set items.n.enabled : true / false depending on role.
  2. Set items.n.style.display : none to hide the option with CSS.
  3. Omit the option from items.

That doesn't sound like a good plan. You should be using roles not users for ease of maintenance and so you don't have to edit the project to add a user.

If your menu is fixed (rather than scripted) then you can use an expression binding on enabled or style.display and something like
hasRole | Ignition User Manual to enable or show the option.

I think the opposite of display : none would be display : inline.

2 Likes