Drupal 7 handle redirect URL after user registerd.

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s