Skip to content

Instantly share code, notes, and snippets.

@atwellpub
Created August 14, 2014 20:02
Show Gist options
  • Select an option

  • Save atwellpub/b6fdebb7b56c68ba3231 to your computer and use it in GitHub Desktop.

Select an option

Save atwellpub/b6fdebb7b56c68ba3231 to your computer and use it in GitHub Desktop.
Example of how to hook into inbound_store_lead_post action hook
<?php
/**
* inbound_store_lead_post runs as an ajax call during a tracked form submission
*
* Use $lead data in crafting 3rd party connection
*/
add_action('inbound_store_lead_post','extension_send_data');
function extension_send_data( $lead )
{
/* URL we want to send the data to */
$external_url = "http://www.remoteservice.com/api/";
/* Uncomment this line print all contents of $lead to your PHP's error_log file for review */
//error_log( print_r( $lead , true ) );
$response = wp_remote_post( $external_url , array(
'method' => 'POST',
'timeout' => 20,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(
'Content-Type' => 'application/json',
),
'cookies' => array(),
'body' => json_encode($lead)
)
);
/* Uncomment this line print the 3rd party response to your PHP's error_log file */
//error_log( print_r( $response , true ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment