BigPurpleDot is a powerful real estate management software for lenders & realtors. You can use their API to send leads from WordPress Contact 7 Form to their CRM platform.
The Code
Edit the variables below ($formId, $apiUser & $apiSecret) and place the code in your current themes functions.php.
$formId – is your Contact Form Id.
$apiUser – can be found in your BPD settings.
$apiSecret– can be found in your BPD settings.
The code below assumes you’re using the fields “you-name”, “your-email”, “your-phone” and “your-message”.
<?php // Place in functions.php function bpd_wpcf7_mail_sent( $form ) { // Contact 7 Form Id $formId = 1; // API User $apiUser = ''; // API Secret $apiSecret = ''; $submission = WPCF7_Submission::get_instance(); if ($submission) { $data = $submission->get_posted_data(); if ($data["_wpcf7"] == $formId) { @list($firstName $lastName) = @explode(" ", $data["your-name"], 2); $notes = sprintf("\r\n\r\nAdditional Information: %s\r\n\r\n", $data["your-message"]); $data_string = json_encode(array( "first_name" => $firstName, "last_name" => $lastName, "phone" => $data["your-phone"], "email" => $data["your-email"], "credit_history" => "", "property_street" => "", "city" => "", "state" => "", "zip" => "", "property_type" => "", "notes" => $notes, "api_user" => $apiUser, "api_secret" => $apiSecret )); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://bigpurpledot.com/api/v1/contacts/vendor_create.json"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $server_output = curl_exec($ch); curl_close ($ch); } } } add_action( 'wpcf7_mail_sent', 'bpd_wpcf7_mail_sent', 10, 1 );