Forum Discussion

kentgilliam's avatar
11 years ago

Conditional based on rank

Can anyone tell me how I change this to render based on rank and not role? Is it as simple as changing "role" to "rank"? I'm doubting it is.    <#assign user_has_role = false /> <#if user.register...
  • VarunGrazitti's avatar
    11 years ago

    kentgilliam - It is indeed as simple as changing role to rank. The benifit in case of the rank vs roles is that a user could have multiple roles, so you would need to iterate through them, but the rank would always be one per user at a give time, it changes with the time and the metrics. So your code would be as below:

     

    <#assign user_has_rank = false />
    <#if user.registered >
    <#list restadmin("/users/id/[id]/ranking").ranking.name as rank>
    <#if rank?? && (rank == "Community Manager" || rank == "rank2" || rank == "rank3")>
    <#assign user_has_rank = true />
    </#if>
    </#list>
    </#if>
    <#if user_has_rank >
    Content will go here
    </#if>