# Customize filterUser function in UserManagement component

**URL:** <https://forum.inductiveautomation.com/t/customize-filteruser-function-in-usermanagement-component/6555>\
**Category:** Ignition\
**Created:** [May 22, 2013, 10:48am UTC](https://forum.inductiveautomation.com/t/customize-filteruser-function-in-usermanagement-component/6555 "2013-05-22T10:48:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlbeltran](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jlbeltran](https://forum.inductiveautomation.com/u/jlbeltran)\
**Post date:** [May 22, 2013, 10:48am UTC](https://forum.inductiveautomation.com/t/customize-filteruser-function-in-usermanagement-component/6555/1 "2013-05-22T10:48:07Z")

</div>

Hi,

I’m using the new “User management” component from Ignition 7.6. What I’m trying to achieve is to filter the users using this code:

`def filterUser(self, user):
     if "Administrador" in system.security.getRoles():
             return 1
     else:
             return 0`

The problem is that the code doesn’t work. However, this same code run from a button it works.  
Do you know what the problem is?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 23, 2013, 9:16pm UTC](https://forum.inductiveautomation.com/t/customize-filteruser-function-in-usermanagement-component/6555/2 "2013-05-23T21:16:39Z")

</div>

It doesn’t work in what way?

Also - this is probably not the best idea. Just configure component security on the component like normal, and make it disabled or hidden.

---

<div class="post-metadata">

**Author:** ![jlbeltran](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jlbeltran](https://forum.inductiveautomation.com/u/jlbeltran)\
**Post date:** [May 28, 2013, 11:03am UTC](https://forum.inductiveautomation.com/t/customize-filteruser-function-in-usermanagement-component/6555/3 "2013-05-28T11:03:31Z")

</div>

We have a project to manage the users where the component must be always visible because the users who can access to this project are administrators or a second group called ‘supervisor’ with less permission than administrators. Both of them can manage the users but we need to restrict that supervisors can not see users with administrator permissions. So we have tried with this code:

```auto
def filterUser(self, user):
     if "Administrador" in system.security.getRoles():
             return 1
     else:
             return 0
```

But it seems that system.security.getRoles() is not working inside of ‘filterUser’ function so my question is if you know what can be the problem.

Thanks,

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 28, 2013, 4:41pm UTC](https://forum.inductiveautomation.com/t/customize-filteruser-function-in-usermanagement-component/6555/4 "2013-05-28T16:41:03Z")

</div>

I think you're misunderstanding what's going on here.

system.security.getRoles() will return the roles of the currently logged in user. I think you're trying to look at the roles of the user that you're filtering! Look at the documentation provided for that extension function:

> [@The Documentation](#):
>
> Call user.getRoles() for a list of rolenames.

---

<div class="post-metadata">

**Author:** ![jlbeltran](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jlbeltran](https://forum.inductiveautomation.com/u/jlbeltran)\
**Post date:** [May 29, 2013, 12:38pm UTC](https://forum.inductiveautomation.com/t/customize-filteruser-function-in-usermanagement-component/6555/5 "2013-05-29T12:38:04Z")

</div>

It seems that I have not explained well, regardless of what I 'm trying to achieve, the code above is a basic example that hide all users if the role of the logged user is not an administrator, is that correct? But the problem is that doesn’t work and I don’t understand what I’m doing wrong.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 29, 2013, 4:12pm UTC](https://forum.inductiveautomation.com/t/customize-filteruser-function-in-usermanagement-component/6555/6 "2013-05-29T16:12:57Z")

</div>

Ok, in that case the code looks fine.

Are you getting any errors in your designer or client console under the logger “Vision.Components.UserManagementPanel”?
