I am experimenting with the Rules module for the first time and I am attempting to redirect my users with some simple php code as below:
drupal_set_message('testing');
drupal_goto('node/3');
The first line of code executes but the second, which should direct my users to node/3, does not have the desired effect.
How can I get this redirecting feature working?
It’s most likely because you have
?destination=some/pathin the page URL, these lines indrupal_goto()cause any path you pass to the function to be overwritten by whatever’s in the URL:You can probably get around it simply by changing your code to this:
If that doesn’t work try adding this line before
drupal_goto:which will reset the static cache for the
drupal_get_destination()function, which also gets involved in this process at some point (I think).If all else fails, go old school:
That’s pretty much nicked straight from the
drupal_goto()function itself and will definitely work.