Typically, you would use the get_avatar filter.
Here’s a code example:
function rdp_wps_get_avatar_filter($avatar, $id_or_email, $size, $default, $alt){
$user = null;
$id = null;
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 )){
$profilePicURL = get_user_meta($user->ID, 'rdp_ll_picture_url',true);
if(empty($profilePicURL))return $avatar;
$avatar = sprintf('<img src="%s" class="avatar user-%2$d-avatar avatar-%4$d photo" width="%4$d" height="%4$d" alt="Profile photo of %3$s" />', esc_attr($profilePicURL),esc_attr($user->ID), esc_attr($user->display_name),esc_attr($size));
}
return $avatar;
}
add_filter('get_avatar', 'rdp_wps_get_avatar_filter', 10, 5);
Hi Robert,
Could you please advice how to use the code above? Should it be added to themes template.php?