Hello,
I noticed a profile picture is only imported if a new account is created on Drupal, but not when user links an existing Drupal account with FB.
The code responsible for this is in
fbouath.fboauth.inc, the function importing pics is in fboauth_create_user
// If the user is already logged in, associate the two accounts.
if ($user->uid) {
fboauth_save($user->uid, $fbuser->id);
drupal_set_message(t('You\'ve connected your account with Facebook.'));
}
// Register a new user only if allowed.
elseif (variable_get('user_register', 1)) {
$account = fboauth_create_user($fbuser);
Comments
Comment #1
quicksketchYep, that's correct. Right now we only add user pictures on registration, not on connecting existing accounts. I'd be happy to review any patches for this feature request.
Comment #2
jay.lee.bio commentedI'd like to see this feature added too. :D
Comment #3
grasmash commentedI needed this feature and implemented it in a custom module. I've made the module available in sandbox mode here: http://drupal.org/sandbox/madmatter23/1493630
I'm toying with the idea of releasing this module, but at the moment I think that it has too few features and too narrow a scope.
Comment #4
gittosj commentedI've managed to prove that my php skills are not sufficient to write a decent patch but here's some hints to save time for anyone who's more skilled than me and can have a go:
The code we need to tweak in in fboauth/includes/fboauth.fboauth.inc and the code that saves the facebook picture to a user's profile is in a block from lines 204 to 227. My instinct is that we should change add a function around line 87 and 95 to retrieve and save the picture (there's no need to do complex user array loads or saves since the 204-227 code writes straight to the database.
Any takers?
Comment #5
gittosj commentedMy experience is that this is a very important issue. Ordinary users are now more and more used to seeing their facebook picture pop up on sites and it gives them some comfort and thrill (!) when it happens. Its a clear visual pointer that they are logged in - my user testing shows that most of them think that no photo means that they're not logged in. Equally 20-30% of users wil register in the normal drupal way and then come back and use the Facebook login button - often because its easier than remembering their password.
So my hacky solution is to add the picture code to a custom php login block (top right corner of header in my case). This displays links and the user's picture. If the user has no picture then it pulls it in from facebook and saves it if not already there - if this is a big security / performance issue then do let me know! Block content is below and input format set to php code:
Comment #6
gittosj commentedActually thinking about it, this would be much better done as a rule that fires on login.
So create a new rule that fires on 'User has logged in'
with an action set to 'Execute custom PHP code'
and paste this into the php code box:
Tested it quite a bit and it seems to cover all scenarios - pulls the users FB picture in as they log in, as long as they already have a picture and have associated their FB account though fboauth. Let me know if you find any bugs or issues
Comment #7
pontusgustafsson commentedTesting, and seems to work just fine! Thanks!
Comment #8
asheeshjoshi commentedHi... this code works great for me. However there is an issue which I am not able to understand if it is because of this code...
I have posted the issue here http://drupal.org/node/1850544
Do you know what could be causing this ? I have not changed anything else in Facebook oAuth module.
Comment #9
asheeshjoshi commentedNever mind. I was able to resolve the issue. Its fixed. And thanks once again for your php script. It works great.
Comment #10
imoreno commented#6 work very well for me, thank you gittosj!
Comment #11
hartogsmith commentedvery helpful -- thanks for your time, effort and brains!
Comment #12
mrded commentedGuys, check out patch from #2101595: Profile picture from Facebook
It should solve your problem.
Comment #13
imoreno commentedcode in #6 is a bit unstable.
while it does import the picture on connect, the site tend to "forget" it and not really store it on the appropriate user field.
so once you visit couple of pages the image is not showing anymore.
any ideas why?
BR
Itzhak
Comment #14
allabakash.g commentedwith reference to #6, instead of Rule, i have updated in the code, it worked!
Comment #15
darrellduane commentedI can confirm that #14 worked. I can now get photos from Facebook to come directly into Drupal's picture for each user that joins the site via FBOauth.
Comment #16
darrellduane commentedThis is in the dev version of this module as of October 2014.
Comment #18
darrellduane commented