# User menu privileges

**URL:** <https://forum.inductiveautomation.com/t/user-menu-privileges/100098>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 20, 2024, 2:00pm UTC](https://forum.inductiveautomation.com/t/user-menu-privileges/100098 "2024-12-20T14:00:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [December 20, 2024, 2:00pm UTC](https://forum.inductiveautomation.com/t/user-menu-privileges/100098/1 "2024-12-20T14:00:44Z")

</div>

Hello!

At the moment when the user access the project is enabled to use some parts of the menu.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/0/102d9052ae1dd0a74860f9b25bece6b50b363263.png)  
so if not enable appear the prohibited icon on rollover

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/9/29442e13c1e7ef21685f9a2ab03bb3a9979ee6ee.png)

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

```python
  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

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 20, 2024, 2:25pm UTC](https://forum.inductiveautomation.com/t/user-menu-privileges/100098/2 "2024-12-20T14:25:38Z")

</div>

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`.

> [@Alejandro\_Alaco](#):
>
> I did it enabling those parts from numbers in the user notes ...

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](https://www.docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/users/hasRole) to enable or show the option.

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

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [December 27, 2024, 9:58am UTC](https://forum.inductiveautomation.com/t/user-menu-privileges/100098/3 "2024-12-27T09:58:03Z")

</div>

```python
def runAction(self):
	try:
	
	    horizontal_menu = self.getChild("root").getChild("HorizontalMenu_0")
	
	    if horizontal_menu is None:
	        raise AttributeError("HorizontalMenu component not found")
	
	    # Get the enabledAccess list from the session custom property
	    enabled_access = self.session.custom.enabledAccess
	
	    filtered_items = []
	    for index, item in enumerate(horizontal_menu.props.items):
	        # Check if index is within the range of enabledAccess
	        if index < len(enabled_access):
	            if enabled_access[index] > 0: # Add to filtered list if enabled
	                filtered_items.append(item)
	
	    # Update the menu's items property with the filtered list
	    horizontal_menu.props.items = filtered_items
	
	except Exception as e:
	    # Log an error message if something went wrong
	    error_message = "Error setting menu item enabled state: {}".format(str(e))
	    system.util.getLogger("HorizontalMenu").error(error_message)

```

Finally I used this code enabling the menu items I want to use, with visibility class didn´t work.

In my case anything over 0 is enabled

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/f/df03525fb59c3228c44c083c7cdc388e0492c7c9.png)

I not using roles because each usr has very specific privileges altough is probably the best way.
