I enabled the Facebook Connect component of this module suite and set it to automatically create accounts for Facebook users (which bypasses the User Registration page). It works well, but up to a point. It does create the account, import the user's picture from Facebook, and redirect to the user-edit screen. However, at this point there are several usability issues:
- The module does not import the user's email address from Facebook, which means that the Email Address field is blank. This is the case both on the user-edit screen and in the {users} table in the database. We should be able to access the user's address via Facebook Connect, as long as the user agrees to let our app access their personal information, right?
- On the same topic-- this is more along the lines of a 'feature request'-- is it possible to map Facebook fields (such as first/last name) to profile fields in Drupal? This is far less critical but I thought I'd mention it.
- When an account is automatically created, Drupal sets a default password. Not having set that password, though, the new user would have no idea what their password is, which is a problem when related to the first item above, because in order to set/change their email address in Drupal 7, a user has to type their password. It seems to me (if it's possible within Drupal) to remove the whole password issue completely for Drupal users who signed up through Facebook Connect, since these users, when they return to your site, will log back in using FB Connect rather than typing a username/password. Is it possible to remove password fields entirely for FB Connect users, which would let them connect to the site and edit their profiles without having to retype a password?
Comments
Comment #1
imoreno commentedHi nateeanes,
Regarding #1
you will have to enable the extended permission module and ask for the "Email - send me emails (email)" permission. once you will do that when a user will approve your application upon login you will have access to his email details.
BR
Itzhak
Comment #2
visuaLatte commentedThanks! That helps. Do you have any idea about #3-- is it possible to use Drupal without a password if you're authenticated through a 3rd-party service like Facebook?
Comment #3
Mackee commentedThe same thing that I need to do. On the drupal for facebook site tour, you can just edit your account and change password.
Comment #4
Mackee commentedProblem was solved, if someone might encounter this check out: http://drupal.org/project/nocurrent_pass
Comment #5
Dave Cohen commentedI haven't really investigated this. My feeling is that drupal core should not prompt for the old password when the user has none.
In the meantime that other module looks like a promising workaround.
Comment #6
skchan2 commenteddid you guys ever figure out #2?
I'm trying to create a user registration form that can prefill fields like first and last name, if the user logs in with FB.
Comment #7
Dave Cohen commentedfb_user.module will do that for name and email fields. Use that code as an example for your custom fields.
It would be great to have a module that somehow adds another option to drupal fields. Something like "get default value from facebook". And their choose which facebook graph path maps to the field path. Really the difficulty is mapping what on facebook corresponds to what on facebook. In practice, I make a snippet of code to do this custom each time and just haven't taken the time to make a module do it in a generic way.
Comment #8
skchan2 commentedI enabled the user module and the fb_user.module will prefill the username and email (after logging in to fb on the "Create Account" page, the username and email field arent prefilled until i refresh the page)
are there any step by step instructions on creating the snippet to prefill custom fields and where it should go?
Thanks for your help on this.
Comment #9
skchan2 commentedAny place I can get in depth instructions? the documentation on drupalforfacebook.org doesn't help.
Comment #10
Dave Cohen commentedhttps://drupal.org/node/195035
https://drupal.org/node/933772
Comment #11
jlea9378 commentedDid you figure out how to get other profile fields and store them in Drupal? I see an example in the links Dave referenced but I can't get them to work. I have the following but it isn't working when I create a new account or update an existing one, but FB Devel shows that the data should be available.
The drupal_set_message call never shows, and the data doesn't get stored in the profile.
Comment #12
Dave Cohen commentedTry letting both anonymous and authenticated users view devel messages, then the dsm() may appear. Or use watchdog() instead.
Comment #13
jlea9378 commentedOh ok. Thanks. Do you see any problems with my code or know why it won't work?
Comment #14
jlea9378 commentedI'm still having troubles figuring this out. This is what I have now:
The dpm($op) call shows that the op is post_external_login. But my attempts to update the user's account fields don't work. Can anyone help?
Comment #15
Dave Cohen commentedThat code when op is post_external_login may be changing the global user, but it wouldn't have any lasting effect. Maybe user_save() afterward would.
When op is FB_USER_OP_PRE_USER, the account hasn't been created yet, so any changes made will be saved for you.
Comment #16
jlea9378 commentedFrom what I could tell during my experimentation, the function was never called during user registration. My site is set up so that users go through registration manually.
I'll try user save and see how that works. Thanks.
Comment #17
jlea9378 commentedThe following code worked for me:
Thanks for your help!