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
Resetting Avatars to Default
The discussion revolves around resetting all user avatars to the default system-generated avatar (the first letter of their username). Brock_Busby requests a query to achieve this, citing a relevant meta post.
TechAPJ provides the necessary server-side commands:
cd /var/discourse
./launcher enter app
rails c
User.human_users.update_all(uploaded_avatar_id: nil)
However, Brock_Busby notes that this will affect system and discobot avatars. TechAPJ confirms this and updates the query to exclude these avatars:
User.human_users.update_all(uploaded_avatar_id: nil)
Brock_Busby reports that running the command worked, but required manual reset of system and discobot avatars. No additional commands (e.g., rebake posts and refresh avatars) are necessary after running the query.
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
Sure @techapj can provide this, may be useful for other sites as well.
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?
This is great @techAPJ. Thank you for this. Two more questions:
And no need to reset on our hosted account. Thanks anyway.
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!
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.