[xwiki-users] isUserInGroup
Hi all, Please, could you help me to find the right syntax to check if an user belongs to a given group? I've been playing with the isUserInGroup method without success. Thank you so much, -- Ricardo Rodríguez Your XEN ICT Team
Hi Ricardo, you need to call it from an user object, hence: - #set ($user = $xwiki.getUser()) ## to retrieve the current user, or getUser("XWiki.UserName") to retrieve any user - $user.isUserInGroup("XWikiAdminGroup") ## to check if this user is in the admin group I didn't try the code, but it should work fine. Vito Your XEN ICT Team - Ricardo Rodriguez wrote:
Hi all,
Please, could you help me to find the right syntax to check if an user belongs to a given group?
I've been playing with the isUserInGroup method without success.
Thank you so much,
Make sure to add in the space, otherwise it won't know what group you're referring to: $user.isUserInGroup("XWikiAdminGroup") should read $user.isUserInGroup("XWiki.XWikiAdminGroup"). Note that there is an easier way to get admin rights though; by using "hasAdminRights()". Otherwise use the isUserInGroup -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Vitantonio Messa Sent: 26 October 2007 11:56 To: XWiki Users Subject: Re: [xwiki-users] isUserInGroup Hi Ricardo, you need to call it from an user object, hence: - #set ($user = $xwiki.getUser()) ## to retrieve the current user, or getUser("XWiki.UserName") to retrieve any user - $user.isUserInGroup("XWikiAdminGroup") ## to check if this user is in the admin group I didn't try the code, but it should work fine. Vito Your XEN ICT Team - Ricardo Rodriguez wrote:
Hi all,
Please, could you help me to find the right syntax to check if an user
belongs to a given group?
I've been playing with the isUserInGroup method without success.
Thank you so much,
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Vitantonio, Brandon, Thanks for your inputs! I can try it now (a whole crew -kids- is awaiting me!), but do that next Sunday evening and keep this thread posted. Cheers, Ricardo -- Ricardo Rodríguez Your XEN ICT Team
Esbach, Brandon wrote:
Make sure to add in the space, otherwise it won't know what group you're referring to: $user.isUserInGroup("XWikiAdminGroup") should read $user.isUserInGroup("XWiki.XWikiAdminGroup").
Note that there is an easier way to get admin rights though; by using "hasAdminRights()". Otherwise use the isUserInGroup
Hi, The following lines reads It works! when current user belongs to the given group (XWiki.XWikiAdminGroup in this case). #set ($user = $xwiki.getUser()) #if($user.isUserInGroup("XWiki.XWikiAdminGroup")) It works! #end Brando: I was aware of the hasAdminRights() option but I need te check users belonging to groups not with admin rights. Thank you so much, -- Ricardo Rodríguez Your XEN ICT Team
Esbach, Brandon wrote:
Make sure to add in the space, otherwise it won't know what group you're referring to: $user.isUserInGroup("XWikiAdminGroup") should read $user.isUserInGroup("XWiki.XWikiAdminGroup").
Note that there is an easier way to get admin rights though; by using "hasAdminRights()". Otherwise use the isUserInGroup
Hi, The following lines produce a nice It works! when the current user belongs to the given group (XWiki.XWikiAdminGroup in this case). #set ($user = $xwiki.getUser()) #if($user.isUserInGroup("XWiki.XWikiAdminGroup")) It works! #end Brando: I was aware of the hasAdminRights() option but I need te check users belonging to groups not with admin rights. Thank you so much, -- Ricardo Rodríguez Your XEN ICT Team
participants (3)
-
Esbach, Brandon -
Vitantonio Messa -
Your XEN ICT Team - Ricardo Rodriguez