Forum Discussion

djksar's avatar
djksar
Maven
13 years ago

checking if user uploaded avatar and bio

I wanted to write some code on whether the user has uploaded their avatar image and inputted their personal bio.  Does anybody have any rest api or freemarker code that I can re-use?  Wanted to promote those two pieces of user-generated content (or lack thereof) and have the following type of message to prompt them "Your profile is 75% complete". Any help would be appreciated. 

 

-Randy

 

 

3 Replies

  • Not sure where you'd want to apply this, but this Freemarker code should give you what you want:

     

    <#assign bio = restadmin("/users/id/${user.id?c}/settings/name/profile.bio").value!"" />
    <#assign avatar = restadmin("/users/id/${user.id?c}/profiles/avatar/url").value!"" />
    
    <#if bio == "" || avatar == "" || avatar?matches(".*serverpage/avatar-name/.*")>
      <div class="custom-profile-status"><font color="#FF0000">Your profile is 75% complete.</font></div>
    </#if>

     

  • djksar's avatar
    djksar
    Maven
    13 years ago
    thanks! Does this take into account the default avatar that everyone gets when they create an account or only those that upload their own.
  • xorrkaz's avatar
    xorrkaz
    Genius
    13 years ago

    Yep.  This code makes sure the user has uploaded an avatar and they are not using a system provided one.