Forum Discussion

yurikleban's avatar
9 years ago

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 t...
  • VarunGrazitti's avatar
    9 years ago

    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>