Created
May 2, 2017 03:21
-
-
Save brooke-heaton/b1a3993a3d1e1f69ccc37e3f3d4b73d9 to your computer and use it in GitHub Desktop.
Drupal 8 Form Alter to redirect User from User Registration Form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_form_FORM_ID_alter(). | |
*/ | |
function mymodule_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'][] = '_mymodule_user_register_form_submit'; | |
} | |
/** | |
* Custom submit handler for registration form. | |
*/ | |
function _mymodule_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
I tried it but give me an error. This is my code if i am doing something wrong please help me out.
`function shortlist_custom_submit(array $form, FormStateInterface &$form_state) {
}`