filterUser() extension function help

Hi all,

I’m trying to filter some users in the User Management component using the filterUser extension function but can’t get it to work for me. I’m sure i’m doing something wrong, just can’t see what it is!

I want to look at the logged in user and basically hide all roles above them in the hierarchy, so Administrator>Lead>Operator where an Admin can sell all users a Lead logged in can only see the same other users with the Lead role and below etc.

I have the following code in the filterUser extension function;

[code]userName = # logged in user
userIn = system.user.getUser("", userName)
rolesIn = userIn.roles # roles for current user
roleNames = user.getRoles() # inspect user role loaded in management table

if “Administrator” in rolesIn:
print “Admin”
return 1
elif “Lead” in rolesIn:
if roleNames == “Administrator”:
print “Success!”
return 0
print roleNames #here my console window shows all roles in management table
return 1
return 0[/code]

I have the print roleNames to help me debug - basically the console window will proceed to display the roles of each user in the management table.

I have 5 users and get the following in the console when logged in with a user with the “Lead” role;


For reference, if logged in as Admin, i get [Admin] in the console 5 times as expected

Any ideas???

Any thoughts anyone?

I think switching line 10 from: if roleNames == "Administrator": to: if "Administrator" in roleNames: should do the trick.


WillMT10, you are a genius my friend! Thank you, this has been driving me stir crazy.