2

I want to redirect after submitting multi-step registration (Two step registration), and also I want to prevent the automatic logging to drupal website after registration completes.

I tried the normal way

$form_state['redirect'] = 'url';  

But it doesn't work.

Then I checked the form action, it also goes to the specified URL after completing the first step.

I just put some of the codes in my module here

function caubo_registration_form_alter(&$form, &$form_state, $form_id) {
if ($form_id != "user_register") return;

// custom codes
.....

if (isset($form_state['storage']['page']) && $form_state['storage']['page'] == 2) {
caubo_register_page_two($form, $form_state);    
return;
}

if (isset($form_state['storage']['page']) && $form_state['storage']['page'] == 3) {   
caubo_register_page_three($form, $form_state);
return;
}
}

I tried the Rules Module and implement the method here, but after completes the registration form, the user is automatically logged in to drupal website, how prevent it?

1

First, make sure no modules with a higher weight than yours are changing the value of $form_state['redirect'] in their hook_form_alter() implementations. Stepping through with Xdebug is a fairly easy way to do this.

If that is not the cause, then it sounds like a call to drupal_goto() is happening somewhere in the process and interrupting the page flow. If your multistep form is working up until the final step, it could well be your own code doing it. Otherwise, check if anything you are doing would trigger any hook implementations or other code that could contain immediate redirects (a.k.a drupal_goto).

Devel can also display a redirection page, which may be a useful feature when debugging this.

Finally, check that $_REQUEST['destination'] isn't being set via the URL or otherwise.

| improve this answer | |
  • Multi-step registration is working fine, but after completes the registration form, the user is automatically logged in to drupal website, how prevent it ? – Ashok KS Nov 17 '11 at 6:05
  • If you don't want them to be able to log in prior to approval, change your user settings to require administrator approval. If you want them to log in themselves but not automatically, call user_logout() - note that user_logout() issues a drupal_goto(), so set $_REQUEST['destination'] or use your own logout function if this is a problem. – wizonesolutions Nov 17 '11 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.