I used this code in function.php:
wpse_49216_my_new_avatar_url function () {
$ gender = xprofile_get_field_data ('ranking', bp_get_member_user_id ());
if ($ gender == "Top 25") {
return 'http://hsseek2.esy.es/wp-content/uploads/2015/04/25.png';
}
if ($ gender == "Top 24") {
return 'http://hsseek2.esy.es/wp-content/uploads/2015/04/24.png';
}
}
add_filter ('bp_core_fetch_avatar_url', 'wpse_49216_my_new_avatar_url');
function wpse_49216_filter_bp_avatar ($ html) {
return preg_replace ('/src=".+?"/', 'src =' 'wpse_49216_my_new_avatar_url ()..' "', $ html);
}
add_filter ('bp_core_fetch_avatar', 'wpse_49216_filter_bp_avatar');
The avatar will not appear outside buddypress page, on any other page it appears. I read on the internet that I must pass the id of the User with bp_loggedin_user_id (). How do I implement this in my code?