Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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;
}
share|improve this question

put on hold as off-topic by toscho 11 hours ago

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Please add debug information to your question to make answers possible. –  toscho Jul 28 '12 at 10:01

2 Answers 2

I would guess that you were expecting the Avatar to show for old / existing comments from people using Twitter or Facebook to login? It's likely that it only will fetch the avatar for new comments

My second guess is that that get_avatar needs to cache or save the users social icon somewhere. So maybe the cache folder has the wrong file permissions.

Did you also try to contact the plugin developer via the WordPress.org support page?

share|improve this answer
    
@Damein yes please have a look here [alturl.com/96e5j] –  Nisha_at_Behance Jul 28 '12 at 14:55
    
@Nisha_Behance that plugin is behaving badly. I logged in with Twitter but it used some other persons profile picture. I think you should remove the plugin as this is not good for your credibility or user security. Perhaps try this plugin ... wordpress.org/extend/plugins/social –  Damien Jul 28 '12 at 18:10
    
@Damein the same plugin used alturl.com/7nvqa please have a look –  Nisha_at_Behance Jul 29 '12 at 15:36

You can use http://wordpress.org/extend/plugins/loginradius-for-wordpress/ plugin for social login implementation and to get the profile avatar from social ID providers.

Thanks!

PS: I'm from LoginRadius Team - we developed and provide support for this WordPress plugin.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.