Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > UsersViewer - Filter users based on role? View modes: 
User avatar
Member
Member
dfurler-liv.asn - 2/1/2012 11:08:46 PM
   
UsersViewer - Filter users based on role?
Hello,

Excuse the dumb question, I have searched but cannot seem to find the answer.

Can anyone please tell me how to use the UsersViewer webpart filter to show only users who belong to a specified role?

Thank you.
David

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/2/2012 3:53:59 AM
   
RE:UsersViewer - Filter users based on role?
Hello,

Yes, you can specify it right in the WHERE condition property of the Users Viewer web part:

WHERE condition: UserID IN (SELECT UserID FROM CMS_UserRole WHERE RoleID = 48)


Best regards,
Jan Hermann

User avatar
Member
Member
dfurler-liv.asn - 2/2/2012 5:37:07 PM
   
RE:UsersViewer - Filter users based on role?
Thanks Jan,

I couldn't actually see a place where RoleID was findable, but in hunting where to find it came across this query which works better for me, so thought I would share in case anyone else finds this post.

UserID IN (select UserID FROM CMS_UserRole  where RoleID = (select RoleID from CMS_Role where RoleDisplayName = 'YourRoleName'))


Not sure if that is more complicated than it need be, but it works.

Thanks again!

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/3/2012 6:16:02 AM
   
RE:UsersViewer - Filter users based on role?
Hello,

Yes, that is actually the same thing I wrote, except you don't have to look into the database and find the RoleID by yourself, but you can fill only the name of the role and its ID is selected from another table.

Best regards,
Jan Hermann