When using the fb_user module on registration, the connect button appears correctly. The user can connect and then the Drupal username field is pre filled with the Facebook name. The Mail field is left empty and a Drupal error appears:

Notice: Undefined index: email in fb_user_form_alter() (line 554 sites/all/modules/fb/fb_user.module

When the user enters his mail manually and hits register, the error appears on the landing page too. The email with the information about the password is send by Drupal as usual.
Is there a possibility to prefile the mail field with Facebook data?

Comments

Crossfeed’s picture

the module isn't requesting the email address so it can't be pre filled. To solve this I found the right place to add the permission request to the authenticate App dialogue:

fb/fb.theme.inc l.26
- $perms = array();
+ $perms = array('email');

Then the dialogue asks also for mail and the register form is pre filled. When the user hits register he is caught in the infinite reload bug.

I use 7.x-3.x-dev patched with the fb_oauth_d7.diff and PHP SDK 3.1.1

wesnick’s picture

Hi,

I think you can make this work by using a hook. In this case, use hook_fb_required_perms_alter(&$perms)

Example usage:

function mymodule_fb_required_perms_alter(&$perms) {
  $perms[] = 'email';
}

After adding this hook, be sure to clear your caches.

The fb_user module will then pick up the email address and add it to your user's data.

Sk1Zy’s picture

Having the exact same problem.

Sk1Zy’s picture

Tried both the solutions by wesnick and crossfeed and neither of them solved the problem for me.

Notice: Undefined index: email in fb_user_form_alter() (line 554 of /home/public_html/sites/all/modules/fb/fb_user.module).

I get this every time i go to the registeration form.

stano.lacko’s picture

In main module is setting:

"Map account when facebook email exactly matches local account"

So I think in it have to be changed to check if this setting is changed,
if yes, add 'email' permision into request, if not, don't ask for this permition.

anyway, with $perms('email') it's working well.

axgalloway’s picture

I got this bug. It displays when you go to the registration page, click the connect and login. Also, it occurs when an anonymous user connects and then goes to the registration page. It is set to not automatically create accounts and checked - Map account when both local uid and Facebook id are known

Notice: Undefined index: email in fb_user_form_alter() (line 552 of /home2/myoutdo1/public_html/beta/sites/all/modules/fb/fb_user.module).

It seems like there should be a simple fix for it, as registration after that still works and links the accounts.
Also, is there a way to redirect to the registration page an anonymous that "Connects"?

The latest library and 7.x dev version are being used.

socialnicheguru’s picture

Issue summary: View changes

Notice: Undefined index: email in fb_user_form_user_register_form_alter() (line 378 of /var/aegir/platforms/7/modules/all/fb/fb_user.module).

email is not necessarily returned by the fb_me() function.

if ($me = fb_me()) {
      $form['account']['name']['#default_value'] = $me['name'];
      $form['account']['mail']['#default_value'] = $me['email'];

I think the proper fix is just to check

if(array_key_exists('email',$me)) {
 $form['account']['mail']['#default_value'] = $me['email'];
}