User Accounts rely on Identity which is how Drupal for Facebook handles users. Identity uses the fb_user.module (User Management) to link Drupal user accounts to Facebook accounts. This supports the notion that Drupal knows you as a local Drupal user and knows your ID on Facebook.

When someone visits your Drupal site and logs on with their Facebook username and password, Drupal for Facebook learns more information about that visitor like their name because they have authorized the application by logging in with their Facebook credentials.

A local account gives your site visitors permission to post in your forums. A map links the two accounts, so the server always knows who they are.

Drupal for Facebook creates this local account to take advantage of profiles, roles, pemissions and other advanced features that come with Drupal.

And, because you know your site visitor's ID on Facebook, Drupal for Facebook can use your friends, groups and social network in ways that Drupal alone could not.

Instant Registration

This is the easiest option for your users. Simply by clicking through the Facebook Connect button (called "authorizing the application") the user will have an account on your server.

Required modules

  • fb_user.module
  • fb_app.module
  • fb_permission.module (if you want to pick up the user email)

Configuration: How to Create Instant Registration for User Accounts

  • Configure an application on Facebook and on your Drupal website as described on the Installation-Application page
  • If you want to synchronise the Facebook email address to the Drupal user account then choose "email" in the Facebook extended permissions

  • Don't forget that for this to actually do anything, you will need to switch on the FB "Extended Permissions" module as well.

  • Once your application has been configured on Drupal, go to Admin >> Site Building >> Facebook Applications >> List and you'll see your newly created app.
  • Under Local Operations click on the edit link so that you can edit settings:


  • Then, you'll see a page like this where you can view your settings:
  • Select the Edit tab in the upper right, open the User settings fieldset at the bottom of page
  • Create a local account: select if user has authorized application as shown below:
  • Enable the Facebook Connect login block under Admin >> Site building >> Blocks and place it somewhere intuitive like the header top region
  • Now, when a user clicks through the Facebook Connect button:
  • their local account will be created and will look like the screenshot demonstration at the bottom of the Installation-Application page.

Delayed Registration

Use this option if your application requires information that cannot be learned from a user's Facebook account info. For example, if your users must accept Terms of Service or some other agreement before proceeding. Or, if you ask for detailed registration information such as an address or phone number.

Required Modules

  • fb_user.module
  • fb_app.module

Configuration: How to Create Delayed Registration for User Accounts

  • Configure the application (same as above)
  • Under Facebook Applications go to the List tab and under Local Operations click on the edit link to edit the application settings (same as above)
  • Open the User settings fieldset at the bottom of page
  • Create a local account: select Do not create automatically
  • Map accounts: select Both local uid and Facebook id are known
  • Map accounts: (optional, but recommended) also select map when e-mail address matches
  • Configure your user registration page to prompt for all the information required by your application. (This process is documented in the profile module)

At this point, Drupal for Facebook will not create accounts; however, an account will be created by Drupal when the user submits the registration page. Then, if the user is connected to Facebook (or connects later), Drupal for Facebook will create a map linking the local account to the Facebook account. So, that in the future, clicking the Facebook Connect button will log the user into the proper local account.

Getting the User's Email Address

By default, Facebook does not share a user's email address with an application. But it does provide a way to get it. The application can request an extended permission to get this (and other information from facebook).

With Drupal for Facebook you have two options for requesting the email extended permission. The first option is to enable the fb_permission.module (found in modules/fb/contrib). This module will let you specify which of facebook's extended permissions are required (or optional) for each of you apps.

The second option is to implement an alter hook. This way your own custom module can control exactly what extended permissions are requested for each login button. Here's an example that requests the email extended perm:

/**
 * Implements hook_fb_required_perms_alter().
 *
 * Builds a list of extended permissions required when authorizing the current
 * facebook app.
 *
 * @see http://developers.facebook.com/docs/authentication/permissions
 */
function fb_example_fb_required_perms_alter(&$perms) {
  if (variable_get('fb_example_require_email', TRUE)) {
    $perms[] = 'email';
  }
}

There is a long list of extended permissions that allow your app to learn various details about a user. The 'email' permission is the only one built into fb_user.module. If you have requested that permission, fb_user.module will save the email address when it creates a new account. It will not attempt to update accounts that were created without that permission, however.

AttachmentSize
local-operations.png43.88 KB

Comments

JPatricioGS’s picture

Thanks for the component, I'm starting to use it and it works fine
I have a comment: it seems the delayed account creation is not working properly, so I've set automatic creation (...)
Where I may start checking/playing in order to propagate data from a facebook account to a drupal account?
I would like to have at least the facebook profile page and an email
Thanks !