Forum Discussion

fuenteso's avatar
fuenteso
Leader
7 years ago

Update a user avatar using the API

Hi everyone,   We're adding new avatars to our community and we want to delete the old ones, which will leave us with a lot of broken avatars.    I've been looking here for a solution and I know ...
  • PerBonomi's avatar
    7 years ago

    We had an issue where users' avatars, especially if they had used external ones at some point, where missing and it looked horrendous.

    I added a one-click button for admins and mods on the profile page that will pick randomly from our set of uploaded avatars.

     

    Long story short, API 1 works just fine for this. The frontend button, on click, pulls from an array of options, then sends the randomly selected one to an endpoint.

    Our endpoint simply does the below. As you can tell from the end it's just set to pick from a certain folder in our assets/avatars section:

    <#assign result = restadmin("/users/id/${user_id}/profiles/name/url_icon/set?value=avatar:candy/Spotify_New/${user_avatar}")/>