diff --git a/ctools_automodal.module b/ctools_automodal.module index e706bc2..939e526 100644 --- a/ctools_automodal.module +++ b/ctools_automodal.module @@ -126,7 +126,19 @@ function ctools_automodal_get_form() { ); $commands = ctools_modal_form_wrapper($form_id, $form_state); - if (empty($commands)) { + if (!empty($form_state['executed'])) { + // We'll just overwrite the form output if it was successful. + $commands = array(); + ctools_add_js('ajax-responder'); + $commands[] = ctools_modal_command_dismiss(t('Login Success')); + if (isset($_GET['destination'])) { + $commands[] = ctools_ajax_command_redirect($_GET['destination']); + } + else { + $commands[] = ctools_ajax_command_reload(); + } + } + elseif (empty($commands)) { $commands[] = ctools_modal_command_loading(); if (!empty($_GET['destination'])) { $commands[] = ctools_ajax_command_redirect($_GET['destination']);