Forum Discussion
Parshant
5 years agoBoss
You can use below code in your custom component with this function to re-use in areas.
<#function user_has_role (id, roles)> <#assign liql = "SELECT id FROM users WHERE roles.name IN (${roles}) and id = '${id}'" /> <#assign query = rest("2.0","/search?q=" + liql?url) /> <#if (query.status == "success") && query.data.size gt 0> <#return true> <#else> <#return false> </#if> </#function>
and call it like this:
<#if user.registered && user_has_role(user.id,"'Administrator', 'Developer'")> ... </#if>
Related Content
- 2 years ago