yurikleban
9 years agoMentor
Exposing a rank
Hey Folks,
Sorry for the newbie q but I was just wondering if anyone has successfully exposed a user ranking in the front-end to the user (based on who the user is, not a hardcoded rank). I was trying to run a simple component that has 'rank - ${rank.name} ' but it is evaluating as null/ missing. Any thoughts?
-Y
yurikleban - You must be trying the component in the logged out state, i.e. if you run this API, you'll get rank name as N/A
/restapi/vc/users/id/-1/ranking/name
Try this code and it should work fine.
<#attempt> <#if !user.anonymous> <!-- Only triggers when the user is logged in --> <#assign rank = restadmin("/users/id/${user.id}/ranking/name").value> Rank - ${rank} </#if> <#recover> <!-- Something went wrong --> </#attempt>