0

I have a form on a WordPress website that sends form input data to Pardot where their prospect account is created. The data is then sent back to the website and caught by user_reg.php where their user account is created for the site. The current form action looks like this:

<form action="pardot.com">

I have some code I wrote that filters out bots the user_reg.php, but it only works on the website and their account is still created in Pardot since it is sent there first.

I need to figure out how to send the form data to user_reg.php, run the bot filtering code, create the website account or (if they're a bot) redirect them to the homepage, then after they're determined not to be a bot and their website account is created send the information to Pardot to create their Pardot account.

form.php

<form action="user_reg.php" method="post" id="main_form" name="main_form">
<table>
 <tr><td><input type="text" maxlength=25 placeholder="Username" id="username" name="username"/></td></tr>
 <tr><td><input type="password" maxlength=25 placeholder="password" id="password" name="password"/></td></tr>
 <tr><td><input type="text" id="brokerdealer" name="brokerdealer" placeholder="Broker Dealer / Company"/></td></tr>
 <tr><td><button type="submit" id="sbmt_btn" name="submt_btn">Send</button></td></tr>
</table>

user_reg.php

// Data validation and blacklist code. If they are determined to be a bot then redirect
// them to homepage. If they are not a bot then proceed to register the user.

if(isset($_POST['submt_btn'])) {

    $username = $_POST['username'];
    $password = $_POST['password'];
    $broker = $_POST['brokerdealer'];

}

// Code to register user in database

// After registering the user, send form data to Pardot

header('location: registration_confirmation.php');

How can I pass the data from user_reg.php which registers the user on the website to pardot.com which creates their prospect account?

Mainfram3
  • 11
  • 5
  • have a look at [wp_remote_post()](https://www.google.com/search?q=wp+remote+post&oq=wpremote+pos&aqs=chrome.1.69i57j0i13l2j0i13i15i30j0i22i30l5.6070j0j7&client=ms-android-samsung&sourceid=chrome-mobile&ie=UTF-8&safe=active&ssui=on) – Moshe Gross Jun 23 '22 at 21:36

1 Answers1

0

You have 2 approaches available to you:

  1. Doing a server-side submit to Pardot, using wp_remote_post() as Moshe Gross suggested in his comment. The down side to this approach is that your visitor's Pardot Tracking Visitor ID will not convert to the Prospect...and Marketing might not be too happy about that.
  2. Doing a browser-side redirect. In WordPress this looks to be a little hacky, but possible (my quick googling only gave me old results, though you may have better luck). With this approach, the down side is that the visitor will actually get bounced around a bit from your form, to the Pardot Form handler URL, then back to your site's final destination. It does tie all the data together though.
Adam Erstelle
  • 2,454
  • 3
  • 21
  • 35