Drupal 7 handle redirect URL after user registerd.

Drupal 7 handle redirect URL after user registerd.

  • 14 July, 2018
  • Renish Khunt
  • Drupal
  • 102

How to handle the redirect URL after user completed the registration process on Drupal7 Custom module. After completing the registration process by default Drupal redirect user to home page. Let’s see how we can handle the redirect URL after complete the registration process.

We can handle registration form redirect URL using the module. I hope you create your own module if not please follow this tutorial.

Let’s create the hook for handle the redirect URL of the registration form.

function thecodingstuff_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'user_register_form') {
        $form['#submit'][] = 'register_form_submit_handler';
    }
}

function register_form_submit_handler(&$form, &$form_state) {
    $form_state['redirect'] = 'product';
}

Just add above method to your module then clear the Drupal cache if enable.

After complete, the registration process user will be redirected to “product” page as per my code. you can change the redirect URL as you want.

If you face any issue after using this hook write the comment below.