You are here

function fbconnect_register_page in Facebook Connect 5

Same name and namespace in other branches
  1. 6.2 fbconnect.pages.inc \fbconnect_register_page()
  2. 6 fbconnect.pages.inc \fbconnect_register_page()

Menu callback. Called when user perform facebook registration

1 string reference to 'fbconnect_register_page'
fbconnect_menu in ./fbconnect.module
Implementation of hook_menu().

File

./fbconnect.module, line 186
This module allows site visitors to connect and register with facebook account

Code

function fbconnect_register_page() {
  if (!($fbuid = fbconnect_get_fbuid())) {
    drupal_set_message(t('Your Facebook session has expired, try to reconnect'));
    drupal_goto();
  }
  if (variable_get('fbconnect_fast_reg', NULL)) {
    $name = fbconnect_get_fbname($fbuid);
    try {

      // "http://wiki.developers.facebook.com/index.php/Proxied_Email"
      $fb_return = facebook_client()->api_client
        ->users_getInfo($fbuid, array(
        'proxied_email',
      ));
      $mail = $fb_return[0]['proxied_email'];
    } catch (Exception $e) {
      watchdog('fbconnect', 'Exception thrown : !code', array(
        '!code' => $e
          ->getMessage(),
      ), WATCHDOG_WARNING);
    }
    $udata = array(
      'name' => $name,
      'pass' => user_password(),
      'init' => $mail,
      'status' => 1,
      'mail' => $mail,
    );
    fbconnect_register_user($udata);
    drupal_set_message(t('Registration successful'));
    drupal_goto();
  }
  else {
    $help_box = t('In order to finalize your registration please choose a username and type in your e-mail address.');
    $output = '<div class="fb-help">' . $help_box . '</div>';
    $output .= drupal_get_form('fbconnect_register_form');
    if ($friends = fbconnect_get_connected_friends($fbuid)) {
      $title = t('My Facebook friends already registered');
      $output .= theme('render_friends_list_fbconnect', $friends, $title);
    }
    return $output;
  }
}