You are here

function fb_user_get_local_user in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 5.2 fb_user.module \fb_user_get_local_user()
  2. 5 fb_user.module \fb_user_get_local_user()
  3. 6.3 fb_user.module \fb_user_get_local_user()
  4. 7.3 fb_user.module \fb_user_get_local_user()

Given an app and facebook user id, return the corresponding local user.

Prefer this to user_external_load(), because that does not honor the module column.

3 calls to fb_user_get_local_user()
fb_actions_cron_per_user in contrib/fb_actions.module
Trigger an action several times, emulating a different user each time. Useful for cron jobs in which we update each users profile box, for example.
fb_user_create_local_user in ./fb_user.module
Creates a local Drupal account for the specified facebook user id.
fb_user_fb in ./fb_user.module
Implementation of hook_fb.

File

./fb_user.module, line 761
This module manages relations between local Drupal user accounts and their accounts on facebook.com.

Code

function fb_user_get_local_user($fbu, $fb_app) {

  // Priority to app-specific map.
  $result = db_result(db_query("SELECT uid FROM {authmap} WHERE authname='%s' AND module='%s'", array(
    $fbu,
    'fb_user_' . $fb_app->label,
  )));
  if (!$result) {

    // non app-specific
    $result = db_result(db_query("SELECT uid FROM {authmap} WHERE authname='%s' AND module='%s'", array(
      $fbu,
      'fb_user',
    )));
  }
  if ($result) {
    return user_load($result);
  }
}