I am trying to use the Rules module to send a form-handler to Pardot using a PHP script when a user logs in. I tested my variables to make sure they were valid by seeing them in a message and they appear fine. The problem I am having is that Pardot does not seem to be getting the form.

The Rules module information

  • Event: 'User Logs in'
  • Condition: none
  • Action: Execute custom PHP Code.

Pardot given form handler link

(similar to)

<form action="http://go.pardot.com/5/38543/2014-03-31/xyz" method="post">

Pardot has a link explaining that I could use an IFRAME instead a Form Action to POST.

Custom PHP Code:

$name = [account:mail];
$FName = [account:profile-user:field-profile-last-name];
$LName = [account:profile-user:field-profile-last-name];
echo '<iframe src="http://go.pardot.com/5/38543/2014-03-31/xyz?name='.$name.'&FName='.$FName.'" width="1" height="1"></iframe>';

Any help?

  • Also I looked in the recent log messages and no error was shown.
    – jnoel10
    Commented Apr 1, 2014 at 18:53

1 Answer 1


It seems the reason why was, that the Iframe was loading and then the page would redirect to wherever the onSuccess page would be set as. So this worked instead.

1- Created a module that hooked the user_login(&$edit,$account) function.

Within the function I defined my variables needed for the form handler, (this example will be email, first name and last name). In my case the First name and Last name were found in the Profile page so I had to get the Profile Id to find them.

$uid = $account->uid;
$mail = $account->mail;
$pid = db_query('SELECT pid FROM {profile} WHERE uid = :uid', array(':uid' => $uid))->fetchField();
$Fname= db_query('SELECT field_profile_first_name_value FROM {field_data_field_profile_first_name} WHERE entity_type = \'profile2\' and entity_id = :pid', array(':pid'=> $pid))->fetchField();
$Lname= db_query('SELECT field_profile_last_name_value FROM {field_data_field_profile_last_name} WHERE entity_type = \'profile2\' and entity_id = :pid', array(':pid'=> $pid))->fetchField();

2- After I used the user_cookie_save(array()) function so I can send the info to the IFRAME after the page loads. (this is still in the user_login function)

        'pardotParams' => '?Email='.$mail.'&FName='.$Fname.'&LName='.$Lname.'&RequestUpgrade='.$RequestUpgrade.'&Serial='.$Serial.'&Industry='
        .$Industry.'&Country='.$Country.'&USFedOrg='.$USFedOrg.'&State='.$State.'&Company='.$Company.'&Phone='.$Phone ,
        'pardotUrl' => $url

3- Lastly, I added this bit of code in the page.tpl.php file found in my template. This will create the iframe off screen but still give it time to load.


  // Comparing the login time to the current timestamp to see if the user just logged in
  if (property_exists($GLOBALS['user'], 'login') 
      && (time() - $GLOBALS['user']->login) < 5 ) {
    // Show the ParDot hidden iFrame. Added some css positioning to move the iframe off the screen
    // as it was throwing off the page alignment regardless of where it was shown in the template.
    echo('<iframe src="http://go.pardot.com/l/38912/2014-03-31/cz7' . 
     $_COOKIE['Drupal_visitor_pardotParams'] . 
     '" width="1" height="1" style="position: absolute; top: -999px; left: -999px;"></iframe>');

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.