Welp.. I figured it out. Here is the code that I placed in my theme’s function.php file so that all avatars are rendered correctly:
function jb_get_bp_user_avatar($avatar, $id_or_email, $size, $default, $alt)
{
if (is_numeric($id_or_email)) {
$id = (int) $id_or_email;
$user = get_user_by('id', $id);
} elseif (is_object($id_or_email)) {
if (!empty($id_or_email->user_id)) {
$id = (int) $id_or_email->user_id;
$user = get_user_by('id', $id);
}
} else {
$user = get_user_by('email', $id_or_email);
}
if ($user && is_object($user)) {
$avatar = bp_core_fetch_avatar(array('item_id' => $user->ID));
}
return $avatar;
}
add_filter('get_avatar', 'jb_get_bp_user_avatar', 10000, 5);
great – thanks for posting the solution
Hey this doesn’t seems to work for me.
Currently I am using following plugins.
* bbPress
* BuddyPress
* Ultimate Member
For all bbPress widgets and shortcode I am unable to force BuddyPress user profile pic.
Can anyone please guide me what am I missing?
Hi,
Any update on this…
Thanks
Hi @robin-w
Any comments from you would be really helpfull.
Thanks
so it works except widgets and shortcode? (and which shortcode?)
I have just found that it works perfectly if I disable Ultimate Member Plugin.
I don’t even require above code and all the user profile pics seems to be working properly.
great – glad you are fixed !!
Hi
I have received solution from UM support.
If you want to use UM plugin with bbPress & BuddyPress you just have to remove filter to disable UM avatar
Checkout this link for more details.
https://wordpress.org/support/topic/buddypress-bbpress-widget-shows-different-profile-pics-with-um-plugin/