35 thoughts on “WordPress Social Login Facebook profile picture”

  1. Thanks ….I have been looking for this information everywhere, I really appreciate it, I am developing this site www,expatsaround.com . & it got me really confused with profile picture sync. thanks again.

  2. I used this same code to grab the LinkedIn avatar via wordpress social login plugin, it worked perfectly.

    Is it possible to modify the wordpress social login plugin to pull additional facebook or LinkedIn fields and map them to buddypress custom profile fields?

  3. Hey… You have a bug in your code:

    Line 36:    $user_id = bp_loggedin_user_id();

    You need to comment out this line.  here is why:

    You are asking for the current User logged In.   However, you want all avatars to display.   So your function emi_user_has_avatar( $user_id=false )  will always return false unless you are the person logged in. 🙂

    You are already passing $item_id into the function, so comment out Line 36 and you will be fine.

    1. Thanks Mauri.

      $user_id = bp_loggedin_user_id();

      was supposed to be

      if( !$user_id ){
      	$user_id = bp_loggedin_user_id();

      logged in user id as the default value if nothing is passed in parameter, but i missed that! :). I’ve updated the code now. Thanks for the heads up.

  4. Hi thanks for sharing this it helped me.

    I think there is a bug in your code line 18 : } elseif ( ‘thumb’ == $type ) {
    $type is undefined.

    DaZ D

  5. This may be a silly question but I am having the same problem but with a different social login plugin.
    (After the user connects, their profile pic is used as the avatar inside wordpress, but not for their buddypress profile)
    Will this code work for me too? Or is it specific to the “WordPress social login plugin”??

  6. It didn’t work for me 🙁 I’m using a plugin called “WP Social MemberLock”.

    I’m confused though, doesn’t WP and BP share the same database? I can see all my user’s profile pics under “wp-admin/users” so why don’t they show for BP? ?


  7. **UPDATE**

    It WORKS! haha! I forgot that I had disabled a setting in the plugin and that was preventing it from grabbing the profile pictures of users. Once enabled your code worked like a charm.


  8. I update this code in function.php in my theme folder. but I am getting below error.

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘revert_to_default_wp_avatar’ not found or invalid function name in /home/xxx/xxxx/wp-includes/plugin.php on line 199

    1. Hi Harry, that function is right there in the code, on second line itself. I am sure, there has been some problem while copying the entire code. Are you sure you copied it properly and your php opening/closing tags are proper?

  9. This method does work on Budypress 2.0 version. After upgeid budypress, all avatars from social network has lost and replaced with gravatars. How to fix it?

  10. I copied the code in my functions.php I am getting no error messages, but when I change my avatar in buddypress or with the theme avatar uploader than nothing is happening. Still 2 different avatars.

    Is this code only working for the very first time you log-in with social log in ? Is there no general possibility to tell buddypress to check for the wp avatar when it loads the bb user profile ? I am using OneAll Social Login

  11. Ohh man, I’m freaking out…. I tried to fix this issue, I copied and pasted this code to the PHP on line 1 before the current PHP, which pushed down the old php to start on line 55. hit update and my website has gone blank, I can not log in to back end as it also is blank, I’m not able to do anything, webpage is gone back end is gone. http://www.TalentTVProductions.com

  12. I don’t understand this, only the home page works, the articles don’t, back end does not, I tried to remove code but not sure I did it right…

  13. Sorry about the distressed posting, got it back to where I started but this code just messed everything up for me, not sure what I did wrong, can someone please help me do this? Thank you and sorry about all the posts.

  14. Its not working anymore with the new versions of buddypress. One or more functions must be outdated?
    It would be so nice if you would update the code above. Cant get it to work properly 🙁


      1. Hi Chandan! how are you? I was using this to fix the problem but since the last buddypress update it is not longer working.

        Do have any idea what can I do to fix it?
        Thanks in advance!

  15. Hi!

    I am endeavoring to get this to work except with the Woocommerce Social login plugin. This code doesn’t work sadly 🙁 If you or anyone has any ideas of how to make this fit – it would be greatly appreciated.

  16. This doesn’t seem to work when I tried it today. I see on the WSL GitHub that something changed in the Facebook API that killed a lot of things. It seems that Facebook is a constantly moving target that requires frequent code updates.

  17. Hey!

    This is exactly what I’ve been looking for.. I’ve added your code to my theme functions.php but it doesn’t work… Has anything changed lately in buddypress / social login?

    I’m using wordpress theme boombox. Social login is working fine but the avatar doesn’t get fetched from facebook.

    Thanks for your work.. 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *