I have created a custom module in which when a user enters a valid id, it should them take them to an external website. The problem I am having is redirecting to the external website. The code I am using in my module is to do the redirection is:

  // clear out the output buffer
  while (ob_get_status()) {
  return header("Location: $external_url");

This doesn't work. What should I be using to accomplish this?



You should use drupal_goto to redirect to a URL.

drupal_goto($external_url, array('referral' => $referral_url));
| improve this answer | |

You should use drupal_goto()

This question is answered in more detail here:

What API function do I use for redirecting to external URLs?

| improve this answer | |

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.