mayank
11 years agoAce
Only Group creators can see Groups
Can anyone please help me so that only Group Creators(Role) can see Groups. <#if user.anonymous == false> <@component id="groups.widget.group-list-view"/> </#if> How can i used a group ...
- 11 years ago
I'm a little late to the party, but I wanted to share a function that I'll often use for seeing if a user has a specific role:
<#-- function: userHasRole Returns true if the user with the specified userId has been granted the role specified by testRole param: userId - Number (not a string) corresponding to the user id of the user to obtain the setting data for param: testRole - String containing the name of the role return: true if the user has been granted the role, false otherwise usage: ${userHasRole(user.id,"Administrator")?string} --> <#function userHasRole userId testRole> <#if (userId)?? && userId?is_number && (userId gt 0) > <#attempt> <#list restadmin("/users/id/${user.id?c}/roles").roles.role as role> <#if role.name?? && (role.name == testRole)> <#return true /> </#if> </#list> <#recover> <#return false /> </#attempt> </#if> <#return false /> </#function>
Sample usage:
<#if userHasRole(user.id,"Administrator")> You're an admin! </#if> <#if userHasRole(user.id,"VIP")> You're a VIP! </#if>