You are here

function simple_fb_connect_user_logout in Simple FB Connect 7.2

Implemets hook_user_logout().

Module configuration allows site builders to define if the user should be logged out also from Facebook after Drupal logout. Facebook logout is done by redirecting the user to an URL generated by Facebook SDK. Facebook returns the user back to our Drupal site immediately after the user has been logged out from Facebook.

We can't redirect the user out from the Drupal site from hook_user_logout() because the hooks are executed just before the Drupal session is terminated. Drupal user_logout performs an internal redirect to home page as the final step of the logout flow so we can set a persistent variable here in hook_user_logout() and then check in hook_drupal_goto_alter() implementation if it has been set and redirect the user to Facebook from there.

File

./simple_fb_connect.module, line 91
Simple Facebook Login Module for Drupal Sites.

Code

function simple_fb_connect_user_logout($account) {
  global $base_url;

  // Validate configuration.
  if (simple_fb_connect_initialize()) {

    // Check if we have a FacebookSession for the current user.
    $fb_session = simple_fb_connect_get_session();
    if ($fb_session && variable_get('simple_fb_connect_logout_action')) {

      // Generate the FB logout URL and store it in a persistent variable.
      $login_helper = new FacebookRedirectLoginHelper('');
      $fb_logout_url =& drupal_static('simple_fb_connect_fb_logout_url');
      $fb_logout_url = $login_helper
        ->getLogoutUrl($fb_session, $base_url . '/');
    }
  }
}