Reset all avatars back to default


(Brock) #1

We would like to reset all users back to default avatar (the first letter of their username).
I saw this post where @codinghorror mentions to run a query.

But can someone please provide the query to reset this?

Thanks in advance


(Jeff Atwood) #2

Sure @techapj can provide this, may be useful for other sites as well.


(Arpit Jalan) #3

To reset all user avatars to system generated avatar, here is what needs to be done on server:

cd /var/discourse
./launcher enter app
rails c
User.human_users.update_all(uploaded_avatar_id: nil)

@Brock_Busby Since you are hosted by us, I can do this for you. Should I go ahead and reset all avatars on your Discourse instance?


(Brock) #4

This is great @techAPJ. Thank you for this. Two more questions:

  1. Will this affect system and discobot avatars?
  2. Do we need to run the rebake posts and refresh avatars command lines after?

And no need to reset on our hosted account. Thanks anyway.


(Brock) #5

Fyi this worked for us but we had to manually reset “system” and “discobot” avatars back to their original value.

So BEFORE you run this command, double check the values in uploaded_avatar_id for “system” and “discobot” and set those back, and you should be good to go!

Thanks for the help all!


(Arpit Jalan) #6

Yes, good point. The original query I mentioned will, here is the updated query that will not:

User.human_users.update_all(uploaded_avatar_id: nil)

(I updated my previous answer to update the query.)

No, nothing else is needed.