Though there are similar issues, I could not find the exact solution. Sorry if this is a repetition!

I have enabled automatic creation of drupal account when a new user logs in using facebook connect. I have also enabled the give access to my email permission. But when a new user accepts the application, his email adress field remains empty. I assume since the permission to access his email is given, the field should be filled automatically. Is there anything I am doing wrong?

I have just updated to the latest version of Drupal for Facebook.

CommentFileSizeAuthor
#12 facebook login.jpg45.86 KBdimon00

Comments

Dave Cohen’s picture

possibly the user.mail column is too short to hold the email address.

medden’s picture

Is there any solution to this problem? where do we find user.mail column ? Do you mean the database table?

luisfn’s picture

I believe that FB don't return users real e-email.

Dave Cohen’s picture

Category: bug » support

In the past facebook might return a "proxy" address, which was very long, too long to fit into Drupal's users table. And many hosts have mysql configured to not even log an error when it fails to save.

Now, if I understand correctly, facebook do the proxy email anymore, but will return whatever email the user has registered with facebook.

fb_user.module will save the mail if it is available the very first time they register. But once the account is created, it will never add the email address. Try deleting the user account and going through the connect process again, making sure to demand the email extended permission.

Also the new auth dialog might let them deny your app the email address. They constantly change that sort of thing.

medden’s picture

Thanks for the clarification Dave.

I tried deleting the user account and re-registering. Still no joy.
If I look at the new user account as admin, it shows a nice devel block that says:

facebook graph for /******:

Array
( [id] => *******
[name] => My Name
[first_name] => My
[last_name] => Name
[link] => http://www.facebook.com/people/My-Name/******
[gender] => female
[email] => si@medden.co.uk
[locale] => en_US
)

So Facebook is certainly not blocking the email, it's just not getting it at registration time, or not passing it to the new drupal account.

Can anyone confirm if this is working for them?

dmiric’s picture

I can confirm that its NOT working ;)

jack_tux’s picture

I CAN confirm that it works for me.

The only change I have done to the base code is at line 680 of fb_user.module

if ($edit['map']) {
    _fb_user_set_map($account, $edit['map']);
  }

Replaced with

if (isset ($edit['map'])) {
    _fb_user_set_map($account, $edit['map']);
  }

This thread has done it a slightly different way http://drupal.org/node/1117214

Not sure if this is the fix, but I definitely do get the fb email address added to the new user's account.

medden’s picture

Thanks for posting your findings Jack. Good to know a simple fix.
In your opinion would it be better to apply the patch from that link? Or to copy your change?

dimon00’s picture

I tried #7 fix but it didn't work for me. :(

Ideas?

Dave Cohen’s picture

#7 is about code in fb_user_user_update(), but this issue is about newly created accounts not containing email. I can't imagine how the two could be related.

It would be more interesting to look at the $info variable in fb_user_create_local_user(). Can you determine whether that array contains an email field?

dimon00’s picture

This is my first time creating a facebook app so I'm not really sure I can be of help (looking into http://drupal.org/node/1117214 as well).

My setting is simple:
- I created an app on facebook,
- I created and app in the fb module setting the parameters ID and Secret,
- I set the app as "Primary connect application",
- Under blocks I enabled the related block (in my case "Facebook Connect Login to CentroVolantini Login"),
- now I can see the connect button,
- I click the button and insert the username and password of a facebook user not yet existing in my drupal,
- connection is fine (but with the last dev version the page is not redirected),
- when I go to the new user details the email is empty.

If you give me instruction I can try to dump the array content.

dimon00’s picture

StatusFileSize
new45.86 KB

I'm uploading the login form.
It doesn't ask permission to share the email address.

If I enable the develop module in users I can see the array:

facebook graph for /XXXXXX:

Array
(
[id] => XXXXXX
[name] => RXXXX XXXXXXXXo
[first_name] => RXXXX
[last_name] => XXXXXXXXo
[gender] => male
[locale] => en_US
)

I was able to get the email by modifying the facebook login block:
Connect

instead of:
Connect

Dave Cohen’s picture

There's two supported ways to request extended permissions.

1) use modules/fb/contrib/fb_permission.module. It adds a fieldset to the app edit form.

2) in your own module, implement hook_fb_required_perms_alter(). You can look over fb_permission_fb_required_perms_alter() as an example.

dimon00’s picture

Solution 1 doesn't seem to work.
If I enable email permission as required in contrib/fb_permission.module I get:
"An error occurred with CentroVolantini Login. Please try again later."

If the email is "optional" it is not requested by the authentication form.

Dave Cohen’s picture

Blame facebook. They include a lot of permissions in their list which don't work and cause that error. Select the other email permission.

imoreno’s picture

dimon00,
In your application settings, did you enabled the "Email - send me emails (email)" extended permission" as it is working for me with that permission.

dimon00’s picture

My fault.
I used "Give my email address" and not "send me emails".

It is working for me too with "send me emails".

Thank you, imoreno. :)

stano.lacko’s picture

In #1278296: Undefined index: email in fb_user_form_alter() is idea for ask for Facebook for users's email.
I think showed idea is working and it's better Idea to have FB connect module better (beacuse admins are looking for problem in module, not in facebook, anyway I don't find any information in documentation for FB module to add this permittion for FB Application).