I need a way for already authenticated users to be able to click a menu link and have a POST submitted to an external site, allowing them to be logged in automatically. This is kind of the opposite from many of the other SSO questions I've seen. I have no control over the other service. Here is where I'm at right now:

  • Created a module that registers the desired path as a page callback function
  • Added a menu link for that path
  • Added a form builder function to generate the necessary fields
  • In the page callback, I'm using drupal_form_submit to submit the form

I've verified that the form, when rendered, has the correct action and method parameters, and all the necessary fields, and when submitted manually, it works as expected, but when submitted programmatically using drupal_form_submit, nothing happens. I don't really have a way of knowing what the redirect URL should be, as it's controlled by the 3rd party site, so I can't use drupal_goto. Is there any way to have drupal_form_submit honor redirects from outside the site? I really don't want to have to use curl directly, if possible.

1 Answer 1


Is there any way to have drupal_form_submit honor redirects from outside the site?

Not really - drupal_form_submit() is invoked as a result of Drupal receiving a form POST on the relevant action URL - it doesn't care about how it's been invoked, and doesn't care about the URL itself (the form's already been submitted, so the action is obsolete by that point anyway).

If you need to POST form data to an external site, but have the processing done by Drupal, your only option is to use cURL or similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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