I am using Wordpress Social Plugin. The problem is that social media's avatar is not showing.
Here is my comment avatar code:
<?php echo get_avatar(get_current_user_id(),30); ?>
I found the get_avatar function in plugin's plugin.ui.php file
add_filter ( 'get_avatar', 'wsl_user_custom_avatar', 10, 5);
function wsl_user_custom_avatar($avatar, $id_or_email, $size, $default, $alt) {
global $comment;
if( get_option ('wsl_settings_users_avatars') && !empty ($avatar)) {
//Check if we are in a comment
if (!is_null ($comment) && !empty ($comment->user_id)) {
$user_id = $comment->user_id;
}
elseif(!empty ($id_or_email)) {
if ( is_numeric($id_or_email) ) {
$user_id = (int) $id_or_email;
}
elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) ) {
$user_id = $user->ID;
}
elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) {
$user_id = (int) $id_or_email->user_id;
}
}
// Get the thumbnail provided by WordPress Social Login
if ($user_id) {
if (($user_thumbnail = get_user_meta ($user_id, 'wsl_user_image', true)) !== false) {
if (strlen (trim ($user_thumbnail)) > 0) {
$user_thumbnail = preg_replace ('#src=([\'"]) ([^\\1]+)\\1#Ui', "src=\\1" . $user_thumbnail . "\\1", $avatar);
return $user_thumbnail;
}
}
}
}
// No avatar found. Return unfiltered.
return $avatar;
}