Skip to content

Instantly share code, notes, and snippets.

@brooke-heaton
Last active June 13, 2017 19:42
Show Gist options
  • Save brooke-heaton/124c61f6720d5c3e0ce837a9948245e9 to your computer and use it in GitHub Desktop.
Save brooke-heaton/124c61f6720d5c3e0ce837a9948245e9 to your computer and use it in GitHub Desktop.
D8 Redirect on registration form
<?php
/**
* Implements hook_form_FORM_ID_alter().
*/
function capitalcamp_glue_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// @todo come up with a more elegant approach here.
// Alter login form and add own custom submit handler.
$form['actions']['submit']['#submit'][] = '_capitalcamp_glue_user_register_form_submit';
}
/**
* Custom submit handler for registration form.
*/
function _capitalcamp_glue_user_register_form_submit($form, FormStateInterface $form_state) {
// Set redirect to login form.
$url = Url::fromUri('internal:/form/registration');
$form_state->setRedirectUrl($url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment