Support » Plugin: Social Login » Weird things happening

  • Resolved jstneti

    (@jstneti)


    I am using this plugin with the WP User avatars plugin.
    Now on my local copy everything works ok – the comments have avatars, but when I test it on a staging site on a live server there are no avatars (not in comment list in the backend) or frontend.
    I’ve checked the DB and I see the images are being saved (same on local and development), but for some reason, they are not displayed – the default fallback image set with WP User Avatar is displayed when users login through OA Social Login.
    Any idea what could be wrong?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Claude

    (@claudeschlesser)

    Hello,

    are the avatars enabled in the social login settings
    in your WordPress admin area?

    Regards,

    Hi,

    The problem was that the WP User Avatar overrides your avatar settings. This didn’t happen with the previous plugin we had.
    So I fixed it by modifying the get_avatar filter. So now it first checks for images saved by your plugin and then if none set sets the default avatar.

    Plugin Author Claude

    (@claudeschlesser)

    Hello,

    thank you for the update! Could you share the modifications that you have done?

    I just added the code below in child theme. Btw there it also a check for images from another social login (previously used).

    add_filter( 'get_avatar' , function( $avatar, $id_or_email, $size, $default, $alt ) {
    	/**
    	 * Get user to get the ID needed below.
    	 * This is a copy from the original filter code form WP as found here: https://codex.wordpress.org/Plugin_API/Filter_Reference/get_avatar
    	 */
    	$user = false;
    	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 );
    	}
    
    	/**
    	 * Get user avatar from oa-social-login and wsl.
    	 * @var [type]
    	 */
    	$user_thumbnail = get_user_meta( $user->ID, 'oa_social_login_user_thumbnail', true );
    	$user_thumbnail_wsl = get_user_meta( $user->ID, 'wsl_current_user_image', true );
    	if ( $user_thumbnail ) {
    		/**
    		 * If oa-social-login avatar exists, display it.
    		 * @var string
    		 */
    		$avatar =  "<img alt='{$alt}' src='{$user_thumbnail}' height='{$size}' width='{$size}' />";
    	} else if ( $user_thumbnail_wsl ) {
    		/**
    		 * If wsl avatar exists, display it.
    		 * @var string
    		 */
    		$avatar =  "<img alt='{$alt}' src='{$user_thumbnail_wsl}' height='{$size}' width='{$size}' />";
    	}
    	return $avatar;
    
    } , 999 , 5 );
    • This reply was modified 2 years, 2 months ago by  jstneti.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Weird things happening’ is closed to new replies.