Skip to content

Instantly share code, notes, and snippets.

@asipple1
Last active January 10, 2019 19:12
Show Gist options
  • Save asipple1/ead0021e3a13f082bcc68a95885665ff to your computer and use it in GitHub Desktop.
Save asipple1/ead0021e3a13f082bcc68a95885665ff to your computer and use it in GitHub Desktop.
use Drupal\Core\Form\FormStateInterface;
function hook_form_alter(&$form, FormStateInterface $form_state, $form_id) {
switch ($form_id) {
// Alter login form and add own custom submit handler.
case 'user_login_form':
$form['#submit'][] = '_statefair_user_login_form_submit';
break;
}
}
/**
* Custom submit handler for login form.
*/
function _user_login_form_submit($form, FormStateInterface $form_state) {
// Set redirect to login form.
$form_state->setRedirect('<front>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment