7

I frequently come across cases in my Drupal 6 sites where a user might encounter my module's pages with the ?destination=foo querystring appended to the URL, from previous interactions on the site. Results of this vary from "inconvenient" to "very aggravating."

The default behavior of drupal_goto() checks for the destination parameter first, and disregards the arguments to drupal_goto() if it is present.

Is there a Drupal-native way to use drupal_goto() in a way that ignores destination?

(Yes, I know I can recreate a version of drupal_goto() in a utility function, but I would prefer a Drupal-native solution if one exists)

14

It's actually quite simple, just unset $_REQUEST['destination'] before you invoke drupal_goto().

  • That's so blindingly obvious, no wonder I missed it :) – anschauung Mar 5 '11 at 0:18
4

Actually, unset($_REQUEST['destination']) doesn't work for me, but I was able to get it work with this instead: unset($_GET['destination']).

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.