# Filter out certian Roles

**URL:** <https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089>\
**Category:** Ignition\
**Created:** [June 3, 2015, 10:32pm UTC](https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089 "2015-06-03T22:32:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bellm](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@bellm](https://forum.inductiveautomation.com/u/bellm)\
**Post date:** [June 3, 2015, 10:32pm UTC](https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089/1 "2015-06-03T22:32:29Z")

</div>

Is there a way to not display certain roles?

What we have is owner, Management, Operator. What I want to do is allow Management to be able to assign roles but I don’t want them to be able to see that there is even a Owner role. So when the user is logged in as owner they have no restrictions, when logged in as management, they can assign roles Management and Operator and when logged in as Operator they have to control.

---

<div class="post-metadata">

**Author:** ![DavidWisely](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/davidwisely/32/10482_2.png) [@DavidWisely](https://forum.inductiveautomation.com/u/DavidWisely)\
**Post date:** [June 4, 2015, 12:29am UTC](https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089/2 "2015-06-04T00:29:43Z")

</div>

I don’t think there is any way to do this with the built in ‘User Management’ component.  
However, you could create your own management forms to do this and customize them any way you want.

---

<div class="post-metadata">

**Author:** ![Pat](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@Pat](https://forum.inductiveautomation.com/u/Pat)\
**Post date:** [June 4, 2015, 1:28am UTC](https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089/3 "2015-06-04T01:28:57Z")

</div>

In 7.7.? they added an Extension Function to the User Management component called filterRole() that can be used to filter Roles.

---

<div class="post-metadata">

**Author:** ![bellm](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@bellm](https://forum.inductiveautomation.com/u/bellm)\
**Post date:** [June 4, 2015, 12:58pm UTC](https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089/4 "2015-06-04T12:58:15Z")

</div>

I found the filter roles but was only able to get it to either filter all or nothing. Do you have a suggestion for how to write it based on each case?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 4, 2015, 1:46pm UTC](https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089/5 "2015-06-04T13:46:43Z")

</div>

`	if role=="owner":
	  return 0
	else:
	  return 1`

---

<div class="post-metadata">

**Author:** ![bellm](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@bellm](https://forum.inductiveautomation.com/u/bellm)\
**Post date:** [June 4, 2015, 2:08pm UTC](https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089/6 "2015-06-04T14:08:50Z")

</div>

[quote=“JordanCClark”]`	if role=="owner":
	  return 0
	else:
	  return 1`[/quote]  
So this just always filters out owner. I am trying to filter out roles to only show the person logged in the roles that they are in and below.

Owner \> Management \> Operator.

So Owner see all, Management sees Management and Operator sees Operator.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 4, 2015, 4:31pm UTC](https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089/7 "2015-06-04T16:31:24Z")

</div>

Was kinda hoping it would spark some ideas for you…

You need to grab the current user, then get role information using [system.user.getUser()](https://support.inductiveautomation.com/usermanuals/ignition/system_user_getuser.htm)

`	userName = system.security.getUsername() # Get currently logged in user
	userIn = system.user.getUser("", userName) # Get User object from UserSource ("" is project default)
	rolesIn=userIn.roles # Get available roles (returns as list)
	if "Owner" in rolesIn: # Check if "Owner" is in the user's role list
	  return 1 # returns everything
	elif "Management" in rolesIn: # Check if "Management" is in the user's role list 
	  if role=="Owner":                         
	    return 0 # disallow "Owner"
	  else:
	    return 1 # allow everything else 
	else: # Otherwise...
	  return 0 # disallow everything`

---

<div class="post-metadata">

**Author:** ![Chris\_Taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chris_taylor/32/3315_2.png) [@Chris\_Taylor](https://forum.inductiveautomation.com/u/Chris_Taylor)\
**Post date:** [June 4, 2015, 4:48pm UTC](https://forum.inductiveautomation.com/t/filter-out-certian-roles/10089/8 "2015-06-04T16:48:33Z")

</div>

What I have done in situations like this is to have two user sources, so in your case:

place the “Owner” in the default user source and the others in a different source and make that source “soft” failover to the default.

In the project properties “Project/General” select the user source for the new source. This way the user management will only show the users for the new source and not the “Owner”.

The downside is that any roles that are unique to the default source will not show in the Security settings in the designer and will have to be scripted on to components. A work around is to add the role to the new user source while designing and use it then, and then delete it from that source after the design is complete, messy but it works
