2

I've been looking for a way to change the default Buddypress avatar for members, and have managed it, partially just using the simple Buddypress codex info here.

BUT

The codex info doesn't quite do the trick. It seems that Gravatar overrides it, so the only way the codex code works is if I first disable gravatar.

The issue that I'm now facing is that in disabling gravatar for buddypress, it disables it across the site so normal wordpress users (say admins/editors) can't edit their avatars through the backend user profile space of wordpress, because it's setup so you can "change your profile picture on gravatar."

BUT

All users could go to their buddypress account page (which we all automatically have no matter how we signed up as long as we have a user account on the site) and they can change their avatar there, which affects it throughout the site.

It's all kinda ok, but not quite right.

So I'm wondering if anyone has a solution that would allow me to set a new default buddypress avatar without having to completely disable gravatar.

Here's the code within the bp-custom.php file:

<?php

// disable gravatar  
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );

//change Buddypress default avatar
define ( 'BP_AVATAR_DEFAULT', 'http://localhost/mysite/wp- 
content/uploads/2017/08/profilpic.png' );
define ( 'BP_AVATAR_DEFAULT_THUMB', 'http://localhost/mysite/wp- 
content/uploads/2017/08/profilpic.png' );

?>
2

Ok so I think I found a solution and wanted to post in case this is an issue for anyone else.

I decided to forgo trying to create a custom default avatar through buddypress specifically, which means I'm no longer talking about using the bp-custom.php file.

Instead I've opted to create a custom gravatar option within the wordpress backend, using my child theme's function file.

I've tried a couple different code versions, but this is what I ended up sticking with:

add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = 'http://example.com/wp-content/uploads/2017/01/wpb-default- 
gravatar.png';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
} 

Add the above code to your theme function file and replace the dummy image address with your desired default gravatar/avatar image for all wordpress users.

Then go to settings > discussion in the wordpress admin area.

You should see your custom avatar image at the bottom of the avatar image list.

Choose that as the default, and save.

Now that image will be the default across all site users, including buddypress, but still allows users to upload their own either through buddypress or through the wordpress admin area via gravatar.

  • This isn't working for me, it's prepending //gravatar.com/... to the start of the URI – david_nash Jun 26 '18 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.