Skip to:

Programmatically assigning avatars to groups?

  • jreeve


    I’m creating a lot of new groups using the wp-cli-bp commandline tool, and I’d like to be able to programmatically give them all the same avatar, an avatar I’ve already uploaded and cropped. Is there a function that will help me select the avatar for groups using their group IDs?

Viewing 4 replies - 1 through 4 (of 4 total)

  • jreeve


    I’ve since discovered that I can filter the function that gets the group avatar, but I just want to set a particular avatar instead of overriding the default. Is there a way to do that?



    Group avatars are stored in /wp-content/uploads/group-avatars/[group_id]

    So to ‘set’ each one, you have to mkdir, create file names, upload a full and & thumb version for each group. I’ve done it; it’s a pita.

    Given that you’re always using the same avatar, filtering the function is easier and would be my choice.



    Great! That’s way simpler than I thought. I saw the images with the UUID-looking filenames, and I assumed that it was more complicated than that.

    I was able to copy one avatar to all the rest with this BASH magic:

    for i in {336..368}; do sudo cp -R 370 $i; done
    for i in {336..368}; do sudo chown -R www-data:www-data $i; done

    where 336 and 368 were the group IDs of the start and end group I wanted to change.



    I’d love to see this option become a part of the core options. I am trying to disable gravatars on all these buddypress. Would be great to have the option for admins to establish a group of avatars that would be auto-used for groups and profiles, removing the third party dependency, saving some privacy, increasing page load speed, and giving communities a better branding by having their own options for default avatars.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Programmatically assigning avatars to groups?’ is closed to new replies.
Skip to toolbar