Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action("gform_post_submission", "vr_subscribe", 10, 2);
- function vr_subscribe($entry, $form){
- // the gform field id numbers
- $gf_field_id_optin = '11.1'; // the gform field id for the subscribe opt-in checkbox
- $gf_field_id_first_name = 9;
- $gf_field_id_last_name = 10;
- $gf_field_id_email = 2;
- $gf_field_id_phone = 3;
- $gf_field_id_state = 12;
- // Vertical Response
- $vr_form_id = '123xyx789eab';
- $source = urlencode('The name of your form');
- $site_admin_email = 'test@test.com';
- if($entry[$gf_field_id_optin]){//opted-in
- //clean up needed?
- $fname = strip_tags($entry[$gf_field_id_first_name]);
- $lname = strip_tags($entry[$gf_field_id_last_name]);
- $useremail = strip_tags($entry[$gf_field_id_email]);
- $phone = strip_tags($entry[$gf_field_id_phone]);
- $state = strip_tags($entry[$gf_field_id_state]);
- $language = false;
- // if using the WPML plugin, pick up the language from the URL
- if(stripos($entry['source_url'],'/es/')!==false){
- $language = 'Spanish';
- } elseif(stripos($entry['source_url'],'/zh-hant/')!==false){
- $language = 'Chinese';
- }
- $url = "http://oi.vresp.com?fid=".$vr_form_id;
- $postFields = "first_name=".$fname;
- $postFields .= "&last_name=".$lname;
- $postFields .= "&email_address=".$useremail;
- $postFields .= "&home_phone=".$phone;
- $postFields .= "&state=".$state;
- $postFields .= "&language=".$language;
- $postFields .= "&source=".$source;
- //Start cURL
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
- //If cURL is successful
- if ($response = curl_exec($ch)) {
- //mail($site_admin_email,"test successful",$url."\n".$postFields,"from:".$site_admin_email);
- } else {
- mail($site_admin_email,"There was an error posting to Vertical Response","Error:\n".$postFields,"from:".$site_admin_email);
- }
- curl_close($ch);
- } else {//didn't subscribe
- //no need to email site admin...
- }
- /* other available gform standard field data:
- id => 4
- form_id => 1
- date_created => 2012-09-27 14:01:53
- is_starred => 0
- is_read => 0
- ip => xx.xx.xx.xx
- source_url => http://...
- post_id =>
- currency => USD
- payment_status =>
- payment_date =>
- transaction_id =>
- payment_amount =>
- is_fulfilled =>
- created_by => 1
- transaction_type =>
- user_agent => Mozilla/5.0 (Windows NT 6.0; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1
- status => active
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement