# Can no longer assign avatar flair by setting primary group

**URL:** https://meta.discourse.org/t/can-no-longer-assign-avatar-flair-by-setting-primary-group/206185
**Category:** Support
**Tags:** rails-console
**Created:** [October 15, 2021, 9:24pm UTC](https://meta.discourse.org/t/can-no-longer-assign-avatar-flair-by-setting-primary-group/206185 "2021-10-15T21:24:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Grayden\_Shand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grayden_shand/32/166586_2.png) [@Grayden\_Shand](https://meta.discourse.org/u/Grayden_Shand)
#### Post date: [October 15, 2021, 9:24pm UTC](https://meta.discourse.org/t/can-no-longer-assign-avatar-flair-by-setting-primary-group/206185/1 "2021-10-15T21:24:41Z")

</div>

I would like to give all users in a group an avatar flair.

I used to be able to set the flair in the group settings, check the “Automatically set as primary group” option, and everyone in the group would automatically get the flair added to their avatar.

Now, however, it seems that a user’s flair is not associated with their primary group. I can verify that a user’s primary group is correctly set, but their avatar still does not display the flair.

While poking around, I noticed a new setting on the user preferences page that allows users to select their own flair.  
﻿﻿  
[![](https://global.discourse-cdn.com/meta/original/3X/f/a/fabe41dfb43c13e7b44779116a6e29cb50ba0291.png) ](https://dl.dropboxusercontent.com/s/g3wzujvzard8l95/Screen%20Shot%202021-10-15%20at%205.13.35%20PM.png?dl=0)

I’m guessing that the addition of this preference setting broke the association between a user’s primary group and their avatar flair.

**Question:** Is there any way now to bulk assign the flair for every user in a group? I don’t want to message the group and instruct them all on how to set this in their preferences, and I don’t want to go through one by one and update each user’s preferences for them.

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [October 28, 2021, 7:11am UTC](https://meta.discourse.org/t/can-no-longer-assign-avatar-flair-by-setting-primary-group/206185/2 "2021-10-28T07:11:19Z")

</div>

This forces group members to have the group avatar:

```plaintext
rails c
 target_group = Group.find_by_name("=GroupSlug=")
 users = User.joins(:group_users).where(group_users:{group_id: target_group.id})
 users.each do |u|
  u.flair_group_id = target_group.id
  u.save
 end
Exit

```

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [October 28, 2021, 4:50pm UTC](https://meta.discourse.org/t/can-no-longer-assign-avatar-flair-by-setting-primary-group/206185/3 "2021-10-28T16:50:30Z")

</div>

[https://github.com/discourse/discourse/pull/14762](https://github.com/discourse/discourse/pull/14762)

I added a fix for this issue in the above PR.

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [July 17, 2022, 3:57pm UTC](https://meta.discourse.org/t/can-no-longer-assign-avatar-flair-by-setting-primary-group/206185/5 "2022-07-17T15:57:46Z")

</div>

I’ve just been trying this again.

I noticed that changes to the primary group setting didn’t seem to update the user’s flair to the group flair. Is the fix above still working?

On a bright note, I improved my little rails console code snippet above so you only need the group slug (and confirmed that it still works!).
