I need to pass the values submitted during registration to Pardot using a form handler.

How can I accomplish the task?


First you'd want to add an additional submit handler to your form...

function pardotpost_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'your_form_id_goes_here') {
    $form['#submit'][] = 'send_to_pardot';

Then in your new submit handler you post the data to their form handler

function send_to_pardot(&$form, &$form_state) {
  $url = 'http://pardot.com/your/form/handler/url/goes/here';
  $data = $form_state['values']['submitted_tree'];
  $options = array(
    'method' => 'POST',
    'data' => http_build_query($data, '', '&'),
    'timeout' => 15,
    'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
  $result = drupal_http_request($url, $options);

Lastly you check $result for any errors. Cheers


Add an additional submit callback to the form.


I have developed a module for this Pardot User Register

Advantage of using this module over adding additional submit callback is site builders / users can easily add the form handler URL in the Drupal admin interface. No coding work involved and the users can check Watchdog for any errors generated from this integration.

Please feel free to create an issue on the project page if you find any. I would be more than happy to fix or enhance the module provided it is a generic bug or suggestion.

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.