function fancy_login_user_login_block_ajax_callback in Fancy Login 8.2
Same name and namespace in other branches
- 7.3 fancy_login.module \fancy_login_user_login_block_ajax_callback()
- 7.2 fancy_login.module \fancy_login_user_login_block_ajax_callback()
- 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 20 - Holds hooks for the Fancy Login module.
Code
function fancy_login_user_login_block_ajax_callback(array $form, FormStateInterface $form_state) {
global $base_url;
$response = new AjaxResponse();
$message_data = drupal_get_messages(NULL, FALSE);
// Check to see if there were any errors with the form submission.
if (!isset($message_data['error'])) {
$config = \Drupal::config('fancy_login.settings');
if ($config
->get('no_redirect')) {
drupal_set_message(t('You have been successfully logged in. Please wait while the page is refreshed.'));
$response
->addCommand(new FancyLoginRefreshPageCommand(TRUE));
}
else {
drupal_set_message(t('You have been successfully logged in. Please wait while you are redirected.'));
$dest = $base_url . $form_state
->getRedirect();
$response
->addCommand(new FancyLoginRedirectCommand(TRUE, $dest));
}
}
$renderer = \Drupal::service('renderer');
$messages = [
'#type' => 'status_messages',
];
$messages = $renderer
->renderRoot($messages);
$selector = '#fancy_login_user_login_block_wrapper';
$response
->addCommand(new AppendCommand($selector, $messages));
return $response;
}