You are here

function fancy_login_user_login_block_ajax_callback in Fancy Login 7.3

Same name and namespace in other branches
  1. 8.2 fancy_login.module \fancy_login_user_login_block_ajax_callback()
  2. 7.2 fancy_login.module \fancy_login_user_login_block_ajax_callback()
  3. 3.0.x fancy_login.module \fancy_login_user_login_block_ajax_callback()

Ajax callback function for fancy_login_user_login_block submit button.

1 string reference to 'fancy_login_user_login_block_ajax_callback'
fancy_login_form_alter in ./fancy_login.module
Implements hook_form_alter().

File

./fancy_login.module, line 427
Holds hooks for the Fancy Login module.

Code

function fancy_login_user_login_block_ajax_callback($form, &$form_state) {
  global $destination;
  $commands = array();
  $form = render($form);
  $message_data = drupal_get_messages(NULL, FALSE);

  // Check to see if there were any errors with the form submission.
  if (!isset($message_data['error']) || !count($message_data['error'])) {
    if (variable_get('fancy_login_no_redirect', 0)) {
      drupal_set_message(t('You have been successfully logged in. Please wait while the page is refreshed.'));
      $commands[] = array(
        'command' => 'fancyLoginRefreshPage',
        'closePopup' => TRUE,
      );
    }
    else {
      drupal_set_message(t('You have been successfully logged in. Please wait while you are redirected.'));
      $dest = $destination && is_array($destination) && isset($destination[0]) ? $destination[0] : $form_state['redirect'];
      $commands[] = array(
        'command' => 'fancyLoginRedirect',
        'closePopup' => TRUE,
        'destination' => url($dest),
      );
    }
  }
  $messages = theme('status_messages');
  $commands[] = ajax_command_replace(NULL, $messages . $form);
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}