You are here

function fbconnect_register_form_submit in Facebook Connect 6

Same name and namespace in other branches
  1. 5 fbconnect.module \fbconnect_register_form_submit()
  2. 6.2 fbconnect.pages.inc \fbconnect_register_form_submit()
1 call to fbconnect_register_form_submit()
fbconnect_register_page in ./fbconnect.pages.inc
Menu callback. Called when user perform facebook registration
1 string reference to 'fbconnect_register_form_submit'
fbconnect_register_page in ./fbconnect.pages.inc
Menu callback. Called when user perform facebook registration

File

./fbconnect.pages.inc, line 105

Code

function fbconnect_register_form_submit($form, &$form_state) {
  $fbuid = fbconnect_get_fbuid();
  if (_is_fbconnect_user($fbuid)) {
    $msg = t("Retrying registration. Your Facebook account already assigned to one account on our site");
    drupal_set_message($msg, 'error');
    watchdog('fbconnect', 'Error creating account for @fbuid', array(
      '@fbuid' => $fbuid,
    ), WATCHDOG_ALERT);
    drupal_goto();
  }
  if (variable_get('fbconnect_fast_reg', NULL)) {
    $user = user_save(NULL, $form_state['values']);
  }
  else {
    $user = $form_state['user'];
  }
  if (!$user) {
    drupal_set_message(t("Error saving user account."), 'error');
    drupal_goto();
  }
  fbconnect_register($user->uid, $fbuid);
  $data['fb_avatar'] = $form_state['values']['fb_avatar'];
  $data['fb_visible'] = $form_state['values']['fb_visible'];
  user_save($user, $data);
  user_external_login($user);
  $_SESSION['fbconnect_feed']['type'] = 'register';
}