Last active
December 21, 2015 14:49
-
-
Save overwine/6322760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function post_save($entry, $form) { | |
$post_url = "http://www.lasikplus.com/ischedule/action/contactRequest.lp"; | |
function format_phone($phone) { | |
var_dump($phone); | |
$phone = preg_replace("/[^0-9]/", "", $phone); | |
$phone = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "$1 $2 $3", $phone); | |
var_dump($phone); | |
return explode(' ', $phone); | |
} | |
$phone = format_phone($entry["5"]); | |
$body = array( | |
'event' => 'saveRequest', | |
'type' => 'contact', | |
'encSource' => 13641, | |
'patient.firstName' => $entry["1.3"], | |
'patient.lastName' => $entry["1.6"], | |
'patient.sex' => $entry["2"], | |
'patient.email' => $entry["3"], | |
'patient.address1' => $entry["4.1"], | |
'patient.city' => $entry["4.3"], | |
'patient.state' => $entry["4.4"], | |
'patient.zipPostal' => $entry["4.5"], | |
'patient.homeAreacode' => $phone[0], | |
'homeNumberA' => $phone[1], | |
'homeNumberB' => $phone[2], | |
'category' => 'brochureRequest', | |
'comment' => 'free-form text', | |
'patient.languagePref' => $entry["6"] | |
); | |
$request = new WP_Http(); | |
$response = $request->post($post_url, array('body' => $body)); | |
} | |
add_filter("gform_entry_post_save", "post_save", 10, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function post_save($entry, $form) { | |
$post_url = "http://www.lasikplus.com/ischedule/action/contactRequest.lp"; | |
function format_phone($phone) | |
{ | |
$phone = preg_replace("/[^0-9]/", "", $phone); | |
$phone = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "$1 $2 $3", $phone); | |
return explode(' ', $phone); | |
} | |
function full_state_to_abbrev($state) | |
{ | |
$list = array( | |
'Alabama' => 'AL', | |
'Alaska' => 'AK', | |
'Arizona' => 'AZ', | |
'Arkansas' => 'AR', | |
'California' => 'CA', | |
'Colorado' => 'CO', | |
'Connecticut' => 'CT', | |
'Delaware' => 'DE', | |
'District Of Columbia' => 'DC', | |
'Florida' => 'FL', | |
'Georgia' => 'GA', | |
'Hawaii' => 'HI', | |
'Idaho' => 'ID', | |
'Illinois' => 'IL', | |
'Indiana' => 'IN', | |
'Iowa' => 'IA', | |
'Kansas' => 'KS', | |
'Kentucky' => 'KY', | |
'Louisiana' => 'LA', | |
'Maine' => 'ME', | |
'Maryland' => 'MD', | |
'Massachusetts' => 'MA', | |
'Michigan' => 'MI', | |
'Minnesota' => 'MN', | |
'Mississippi' => 'MS', | |
'Missouri' => 'MO', | |
'Montana' => 'MT', | |
'Nebraska' => 'NE', | |
'Nevada' => 'NV', | |
'New Hampshire' => 'NH', | |
'New Jersey' => 'NJ', | |
'New Mexico' => 'NM', | |
'New York' => 'NY', | |
'North Carolina' => 'NC', | |
'North Dakota' => 'ND', | |
'Ohio' => 'OH', | |
'Oklahoma' => 'OK', | |
'Oregon' => 'OR', | |
'Pennsylvania' => 'PA', | |
'Rhode Island' => 'RI', | |
'South Carolina' => 'SC', | |
'South Dakota' => 'SD', | |
'Tennessee' => 'TN', | |
'Texas' => 'TX', | |
'Utah' => 'UT', | |
'Vermont' => 'VT', | |
'Virginia' => 'VA', | |
'Washington' => 'WA', | |
'West Virginia' => 'WV', | |
'Wisconsin' => 'WI', | |
'Wyoming' => "WY" | |
); | |
return $list[$state]; | |
} | |
$phone = format_phone($entry["5"]); | |
$state = full_state_to_abbrev($entry["4.4"]); | |
$body = array( | |
'event' => 'saveRequest', | |
'type' => 'contact', | |
'encSource' => 13641, | |
'patient.firstName' => $entry["1.3"], | |
'patient.lastName' => $entry["1.6"], | |
'patient.sex' => $entry["2"], | |
'patient.email' => $entry["3"], | |
'patient.address1' => $entry["4.1"], | |
'patient.city' => $entry["4.3"], | |
'patient.state' => $state, | |
'patient.zipPostal' => $entry["4.5"], | |
'patient.homeAreacode' => $phone[0], | |
'homeNumberA' => $phone[1], | |
'homeNumberB' => $phone[2], | |
'category' => 'brochureRequest', | |
'comment' => 'free-form text', | |
'patient.languagePref' => $entry["6"] | |
'event' => 'saveRequest', | |
'type' => 'contact', | |
'encSource' => 13641, | |
'patient.firstName' => 'John', | |
'patient.lastName' => 'Tester', | |
'patient.sex' => 'M', | |
'patient.email' => '[email protected]', | |
'patient.address1' => 'Parkway 11', | |
'patient.city' => 'Dayton', | |
'patient.state' => 'OH', | |
'patient.zipPostal' => 12345, | |
'patient.homeAreacode' => 420, | |
'homeNumberA' => 739, | |
'homeNumberB' => 7461, | |
'category' => 'brochureRequest', | |
'comment' => 'free-form text', | |
'patient.languagePref' => 'Spanish' | |
); | |
var_dump($body); | |
$request = new WP_Http(); | |
$response = $request->post($post_url, array('body' => $body)); | |
var_dump($response); | |
} //post_save | |
add_filter("gform_entry_post_save", "post_save", 10, 2); | |
------------------------------ | |
function post_save($entry, $form) { | |
$post_url = "http://www.lasikplus.com/ischedule/action/contactRequest.lp"; | |
$body = array( | |
'event' => 'saveRequest', | |
'type' => 'contact', | |
'encSource' => 13641, | |
'patient.firstName' => 'John', | |
'patient.lastName' => 'Tester', | |
'patient.sex' => 'M', | |
'patient.email' => '[email protected]', | |
'patient.address1' => 'Parkway 11', | |
'patient.city' => 'Dayton', | |
'patient.state' => 'OH', | |
'patient.zipPostal' => 12345, | |
'patient.homeAreacode' => 420, | |
'homeNumberA' => 739, | |
'homeNumberB' => 7461, | |
'category' => 'brochureRequest', | |
'comment' => 'free-form text', | |
'patient.languagePref' => 'Spanish' | |
); | |
$request = new WP_Http(); | |
$response = $request->post($post_url, array('body' => $body)); | |
} //post_save | |
add_filter("gform_entry_post_save", "post_save", 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment