I have tried everything to override the BP Avatar. Found about 5-6 different Google results that basically all point to the same solution:
function override_bp_member_avatar($url) {
return get_stylesheet_directory_uri() . '/default_avatar.png';
}
add_filter('bp_core_fetch_avatar_no_grav', '__return_true'); // http://codex.buddypress.org/extending-buddypress/tips-tricks/
add_filter('bp_core_mysteryman_src', 'override_bp_member_avatar'); // http://www.buddyboss.com/instructions/
Yet it does not work.
Has anyone had success using a default Avatar for members?
The filters you cite are only for the default/fallback avatars. If you want to replace BP avatars altogether, the key filters are
bp_core_fetch_avatar
andbp_core_fetch_avatar_url
. The latter filters the entire HTML avatar element, while the latter does just the URL.How you do the filtering depends on how fancy you want to get. The
bp_core_fetch_avatar
passes along a lot of useful parameters, if you want to totally rebuild the avatar HTML: https://buddypress.trac.wordpress.org/browser/tags/1.5.5/bp-core/bp-core-avatars.php#L297 Otherwise, for a quick fix, you could justpreg_replace()
the URL.EDIT: The above method will replace all avatars. If you only want to change the default/fallback avatar (for users who have not uploaded their own), try