Try adding following code at the end of functions.php
file of your current theme/child theme:
/**
* Replace default avatar with social avatar
*/
function heateor_ss_custom_social_avatar($avatar, $avuser, $size, $default, $alt = '') {
global $theChampLoginOptions;
if(isset($theChampLoginOptions['avatar_quality']) && $theChampLoginOptions['avatar_quality'] == 'better'){
$avatarType = 'thechamp_large_avatar';
}else{
$avatarType = 'thechamp_avatar';
}
$userId = 0;
if(is_numeric($avuser)){
if($avuser > 0){
$userId = $avuser;
}
}elseif(is_object($avuser)){
if(property_exists($avuser, 'user_id') AND is_numeric($avuser->user_id)){
$userId = $avuser->user_id;
}
}
if($avatarType == 'thechamp_large_avatar' && get_user_meta($userId, $avatarType, true) == ''){
$avatarType = 'thechamp_avatar';
}
if(!empty($userId) && ($userAvatar = get_user_meta($userId, $avatarType, true)) !== false && strlen(trim($userAvatar)) > 0){
return '<img alt="' . esc_attr($alt) . '" src="' . $userAvatar . '" class="avatar avatar-' . $size . ' " height="' . $size . '" width="' . $size . '" />';
}elseif(function_exists('um_fetch_user')){
if ( is_numeric($avuser) )
$userId = (int) $avuser;
elseif ( is_string( $avuser ) && ( $user = get_user_by( 'email', $avuser ) ) )
$userId = $user->ID;
elseif ( is_object( $avuser ) && ! empty( $avuser->user_id ) )
$userId = (int) $avuser->user_id;
if ( empty( $userId ) )
return $avatar;
um_fetch_user( $userId );
$avatar = um_user('profile_photo', $size);
if ( !um_profile('profile_photo') && um_get_option('use_gravatars') ) {
if ( is_ssl() ) {
$protocol = 'https://';
} else {
$protocol = 'https://';
}
$default = get_option( 'avatar_default', 'mystery' );
if ( $default == 'gravatar_default' ) {
$default = '';
}
$rating = get_option('avatar_rating');
if ( !empty( $rating ) ) {
$rating = "&r={$rating}";
}
$avatar = '<img src="' . $protocol . 'gravatar.com/avatar/' . md5( um_user('user_email') ) .
'?d='. $default . '&s=' . $size . $rating .'" class="gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="" />';
}else if( empty( $avatar ) ){
$defaultAvatarUri = um_get_defaultAvatarUri();
$avatar = '<img src="' .$defaultAvatarUri .'" class="gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="" />';
}
}
return $avatar;
}
add_filter('get_avatar', 'heateor_ss_custom_social_avatar', 100000, 5);