You are here

function fbconnect_association_form_submit in Facebook Connect 5

Handle post-validation association_Form submission.

When the user submits this form, an association of the drupal uid and the facebook fbuid is inserted into the table fbconnect_users.

File

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

Code

function fbconnect_association_form_submit($form, &$form_state) {
  if ($fbuid = fbconnect_get_fbuid()) {
    if ($form_state['link'] == 1) {
      $user = user_load(array(
        'uid' => arg(1),
      ));
      if (fbconnect_register($user->uid, $fbuid)) {
        drupal_set_message(t('Congratulations! Your account is now linked to your Facebook account'), 'status');
        watchdog('fbconnect', 'User uid: !user is now associated with the fbuid: !fbuid.', array(
          '!user' => $user->uid,
          '!fbuid' => $fbuid,
        ));
      }
      else {
        drupal_set_message(t('Association failed'), 'error');
        watchdog('fbconnect', 'User association failed for uid: %user - fbuid: %fbuid.', array(
          '!user' => $user->uid,
          '!fbuid' => $fbuid,
        ));
      }
    }
  }
}