How To Integrate Zapier and WordPress Form - Filip Rastovic

How to Integrate Zapier and WordPress to Make a Double Opt In Process

My client had many forms on his website and they were all part of a double opt-in process. A visitor had to fill out the form, see a notification that will let him know he should verify his email address and then click a unique url in his email client that will take him back to my clients website where he will see a thank you page. The url that gets sent to the visitors email is unique and my client wanted to have the contents of that url sent to zapier webhook so he has the info about. The process corresponds to a classic double opt-in process. The email is sent to the user from another system (may come from different systems) and contains a confirmation link. In the code snippet bellow, we parse the unique url a client has clicked in his email address, create a json object out of it and then send it over to Zapier.



// Zapier hook
$url = ‘’;

// Get the current url and parse it
$actual_link = “http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”;

$zapierData= parse_url( $actual_link, PHP_URL_QUERY );

// Split the url into an json object with key value pairs from the URL
$keywords = preg_split( “/[\s,=,&]+/”, $zapierData );

$arr = array();

for ( $i = 0; $i < sizeof( $keywords ); $i++ ) {

$arr[ $keywords[ $i ] ] = $keywords[ ++$i ];


$obj = ( object ) $arr;

$toSend = json_encode( $obj );

// Send data to zapier
$headers = array( ‘Accept: application/json’, ‘Content-Type: application/json’ );

zapier( $url, $toSend, $headers );

function zapier( $url, $json, $headers ) {

$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, $url );

curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch, CURLOPT_TIMEOUT, 10 );

curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, ‘POST’ );

curl_setopt( $ch, CURLOPT_POST, true );

curl_setopt( $ch, CURLOPT_POSTFIELDS, $json );

curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );

$output = curl_exec( $ch );

curl_close( $ch );


Are we a match?

While we welcome inquiries from all types of companies that use websites, experience has shown we obtain the best result for clients with the following traits...

  • Have an opportunity to build growth through their marketing plan
  • Are running paid advetising
  • Recognize their website is a valuable marketing asset
  • Value a structured process to ensure great results

Schedule your consultation!