mudmin/usplugins

Profile picture from facebook

Opened this issue · 0 comments

tomu4 commented

It would be nice if facebook_login plugin could also update user profile image with facebook one. It's super easy, I already tested that by modifiing code on my website, all that has to be done in fb-callback.php file is (bold represents changes to be done):

  • add line: $pic = "http://graph.facebook.com/".$fbuser['id']."/picture?type=large"; (in my case it's on line 118 right above user existance check)
  • edit fields line when user exists: $fields=array('fb_uid'=>$fbuser['id'], 'logins'=>$newLoginCount, 'last_login'=>$newLastLogin , 'picture'=>$pic); (in my edited version line 125, originally propably little bit higher)
  • edit fields line when user doesn't exist: $fields=array('email'=>$fbEmail,'username'=>$username,'fname'=>$fb_fname,'lname'=>$fb_lname,'permissions'=>1,'logins'=>1,'join_date'=>$date,'last_login'=>$date,'email_verified'=>1,'password'=>NULL,'fb_uid'=>$fbuser['id'] ,'picture'=>$pic); (in my case line 176, originally propably little bit higher)

And that is that. This simple edit gets URL of facebook profile image, which can than be used instead of Gravatar URL. This basically makes registration easier for users, because they don't need to upload their profile picture anywhere, it also automatically updates with facebook profile picture update.

I already sucessfully implemented and tested these changes on my website, I just thought someone else could appreciate it and they won't need to reinvent the wheel. If you don't think it's good idea to implement it or you find better solution, feel free to ignore this.