Hi @multimartin
I just tried searching the WP plugin repo and came across an old plugin that may be of some help. Take a look at Remove Avatars
Hi @henrywright
Thanks for the reply. I checked out that plug-in and it just removes the avatar from displaying on the BuddyPress profile – it still actually retains the ‘Mystery Man’ style avatar as opposed to using the one set in WordPress.
Martin
Humm.. not helpful then. In that case we might have to try doing it manually. Perhaps try disabling the filter which replaces the WP avatars with BP avatars. For example, add this to your theme’s functions.php file:
remove_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 );
I think you can disable the Gravatar fallback as well with this:
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
If that doesn’t work, you may need to replace all occurrences of bp_core_fetch_avatar()
with get_avatar()
in your templates. But cross that bridge when you come to it.
Ref: https://codex.wordpress.org/Function_Reference/get_avatar
Hi @henrywright
Sadly this hasn’t worked either. I added both lines to the functions.php of the child theme and it still displays the ‘Mystery Man’ π
In the back-end it’s also displaying the avatars as Mystery Men too.
Actually scratch that last post – it’s now displaying the avatars as the WordPress avatars in the back-end but not the front end!
Actually scratch that last post β itβs now displaying the avatars as the WordPress avatars in the back-end but not the front end
In that case, I think we’ve just crossed that bridge hehe. i.e the next step will be to replace all instances of bp_core_fetch_avatar()
in your front-end templates with get_avatar()
Thanks @henrywright…
I’m not entirely sure that my front-end template actually references bp_core_fetch_avatar() as it is not a BuddyPress theme but rather a regular WordPress theme (Responsive Pro).
Martin
It will do, sort of indirectly, actually. For more info on how it works, check out the Template Hierarchy article.
So I’m checking the theme files and not the BuddyPress files? How would it be referenced in the theme files. Sorry – bit of a beginner with this and appreciate your help π
If your theme doesn’t explicitly use BuddyPress templates then the default templates will be used. For a quick look at the templates check out the GitHub repo.
I’m guessing your theme doesn’t explicitly use the templates so what you’d have to do is create them yourself. The general idea is to create a folder called buddypress
inside your theme and then add the templates you’d like to customise to that folder. So for example, you’d end up with /wp-content/themes/your-theme/buddypress/
. Everything goes inside there.
Okay, so searching that GitHub repo there is only one file under the bp-themes/bp-legacy/buddypress folders which mentions bp_core_fetch_avatar()
(but lots within the core BuddyPress code. So I just need to replace the reference in that one file and add it to by child theme under a BuddyPress folder and it should work?
There might actually be more things you’d need to do. For example, the bp_get_message_thread_avatar()
function uses bp_core_fetch_avatar()
so you would need to filter that using bp_get_message_thread_avatar
etc.
Unless someone else knows of an easier way, it seems as though it’ll be a big task of going through everything. You’d also need to be comfortable with PHP.
Alternatively, you could try disabling avatars by adding this to your bp-custom.php file
define( 'BP_SHOW_AVATARS', false );
Note: I’ve not tested that, I’m just going on what I see at the beginning of the bp_core_fetch_avatar()
function. i.e:
// If avatars are disabled for the root site, obey that request and bail
if ( ! buddypress()->avatar->show_avatars )
return;