Is the current user logged into facebook?

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

fb_facebook_user()

fb.module provides a method, fb_facebook_user(), which returns the user's ID on facebook. It will return a positive integer if a) the user is logged into facebook and b) has authorized your application. In other words, if they are connected this function returns their ID.

if ($fbu = fb_facebook_user()) {
  // The user is connected to facebook and $fbu is their ID.
}
else {
  // The user is ether not logged into facebook or has not authorized the application.
}

fb_get_fbu()

fb.module also provides fb_get_fbu(), which will tell you whether a local drupal account is connected to a facebook account. This will return a facebook user id regardless of whether the user is currently logged into drupal of facebook.

if ($fbu = fb_get_fbu(42)) {
  // The local user with uid == 42 is mapped to a facebook ID ($fbu).
}
else {
  // The local user with uid == 42 is not connected to facebook.
}

Help improve this page

Page status: Not set

You can: