WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Social Login
[resolved] Account Email and Avatars (15 posts)

  1. snatrott
    Member
    Posted 2 years ago #

    I am using BuddyPress, and the plugin logs a user in just fine using Twitter and LinkedIn (I am not using any others).

    However, the Account Email in the user's settings shows:
    linkedin_user_john_doe@example.com (it says my name rather than john doe, but example.com is actually what is written)

    I need it to use the email that the user signed into the social site with.

    Also, the avatar never shows up in the login form area, profile or comments areas.

    http://wordpress.org/extend/plugins/wordpress-social-login/

  2. snatrott
    Member
    Posted 2 years ago #

    Does anyone know of a way to fix this or will it be fixed in the next release?

    This is the best social login I could find, and it is useless if the email doesn't work when logging in.

  3. berlotti
    Member
    Posted 2 years ago #

    Hi snatrott,

    How did you manage to link buddypress users to wordpress users??

    (i'm still facing this issue: http://wordpress.org/support/topic/plugin-wordpress-social-login-integration-with-buddypress )

  4. snatrott
    Member
    Posted 2 years ago #

    I didn't do anything special to connect buddypress and wordpress users. I am using WP 3.3.1 and BuddyPress 1.5.3.1. The users were automatically added to the regular user area.

  5. jlnd
    Member
    Posted 2 years ago #

    The wsl_user_custom_avatar function in wordpress-social-login/includes/plugin.ui.php, which is borrowed from the Social Login plugin, only gets the social networking avatar for comments on the front end. It does not get the avatar for the user's admin bar or in the admin area users list, etc.

    To make the social networking avatars work throughout, you can put this code into your theme or a custom plugin...

    // remove WordPress Social Login's get_avatar filter so that we can add our own
    remove_filter( 'get_avatar', 'wsl_user_custom_avatar' );
    function my_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;
    }
    
    add_filter ( 'get_avatar', 'my_user_custom_avatar', 10, 5);

    ...Or, if you want to hack the WSL plugin, you could replace the content of the wsl_user_custom_avatar function in wordpress-social-login/includes/plugin.ui.php with the content of the my_user_custom_avatar function above.

  6. jlnd
    Member
    Posted 2 years ago #

    Email is not one of the fields that LinkedIn makes available to pull in via their API:
    https://developer.linkedin.com/documents/profile-fields (In the code comments of the plugin there's a note that "Currently only Facebook, Google, Yhaoo and Foursquare do provide the verified user email.") So the WP Social Login plugin generates a fake email for the user. The code is in wordpress-social-login/includes/plugin.auth.php.

    Perhaps the email field could just be left blank, but maybe that would keep the login process from continuing properly. I'll be testing this soon.

  7. Miled
    Member
    Plugin Author

    Posted 2 years ago #

    as jlnd said, not all networks provide the user email, and we simply have to create a fake one to complete the user registration.

    also i added the code provided by jlnd to display the user avatar ( this should be available on the next release as well)
    Thanks a lot!

  8. enderpal444
    Member
    Posted 2 years ago #

    @jlnd I put you function into the functions.php of my child theme for buddypress but nothing changed. The only place the avatar shows up is in the comment form. It doesn't show where I use bp_loggedin_user_avatar, bp_displayed_user_avatar, and bp_core_fetch_avatar. It does appear to work for get_avatar though. What can I add to make it work on all of those places?

  9. jlnd
    Member
    Posted 2 years ago #

    @enderpal444, I don't use Buddy Press so I'm not positive but you might be able to get things to work by rearranging the priority order of your filters. In the code above, try changing the 10 in the last line to 15.

    If that works, it might be necessary to customize the function a bit to only use the social avatar if buddy press doesn't have one. To do so, add the following code at the 4th line (the blank line)...

    // Only continue if there is no buddy press avatar
    if( $avatar != '' && strpos($avatar, 'gravatar') === false ) {
    return $avatar;
    }

  10. enderpal444
    Member
    Posted 1 year ago #

    Hi jlnd! This still isn't working for me =(. Any other ideas? This would be so perfect for me if I could get this to work.

  11. ivnus
    Member
    Posted 1 year ago #

    What we need is a popup dialog box for users that login with a service that does provide an email.

    "Please enter your email to continue logging"

    I know this plugin has this feature "http://wordpress.org/extend/plugins/loginradius-for-wordpress/", but I don't like how its a SaaS.

    Anyway of making this happen? I'll supply the coffee :)

  12. mudandroutes
    Member
    Posted 1 year ago #

    I'm having similar issues with:
    1 - none of the avatars pulling through
    2 - the lack of email address from some social networks. This is a problem as I've a form setup that allows registered users to claim a free blog where I depend on them updating their email address.

    The enter your email as mentioned above would just be a tidier, more elegant solution! I previously had the LoginRadius plugin running and it did all that, but didn't play nicely with a multisite install.

    If Ivnus is bringing the coffee, shall I bring the biscuits (cookies)?

  13. knaveenchand
    Member
    Posted 1 year ago #

    The problem still persists. I guess the theme author has included the code provided by @jlnd in this thread above. I have downloaded the latest version of this plugin but the avatars ain't getting generated.

    I have installed Theme-my-login plugin and interestingly, the avatar displayed in the sidebar by Theme-my-login gives excellent results of fetching the avatar from social networks. But the avatars on the members page still remains blank.

    So my conclusion is that the bug is in the theme - not with the wordpress social login plugin.

    I am not sure, though, where to find that bug in the theme files. I am using default buddypress theme with buddypress enabled.

  14. mudandroutes
    Member
    Posted 1 year ago #

    I was previously using the plugin by Login Radius which pulled the avatars through fine but wasn't suitable for multisite. So in my case, the issue has started when I changed to this plugin.

    What I can't confirm is whether it's a permissions issue with my hosting, which is the only other thing that changed in the same period.

  15. ivnus
    Member
    Posted 1 year ago #

    @mudandroutes - I know they say Login Radius works for Multisite, but what did you find bad about the Login Radius plugin?

    I was thinking of switching until WP Social Login was setup to ask for email addresses on twitter, linkedIn sign ins, and domain name SSO.

    I think I can safe speak for myself and mudandroutes, that we would both love to see these features.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic