Limit Contact Form 7 hook (Before Send) to specific form
-
I have a website with 3 form, but only two of these forms must enter information into the Salesforce database. How do I define which forms should use the hook and which shall without going through it?
Follow the code I’m using:
add_action( 'wpcf7_before_send_mail', 'my_conversion' ); function my_conversion( $contact_form ) { $title = $contact_form->title; $submission = WPCF7_Submission::get_instance(); if ( $submission ) { $posted_data = $submission->get_posted_data(); } $email = $posted_data["your-email"]; $name = $posted_data["your-name"]; $last = $posted_data["your-lastname"]; $phone = $posted_data["tel-71"]; $description = $posted_data["your-message"]; $post_items[] = 'oid=00D4000000xxxxx'; $post_items[] = 'first_name=' . $name; $post_items[] = 'last_name=' . $last; $post_items[] = 'company='; $post_items[] = 'email=' . $email; $post_items[] = 'phone=' . $phone; $post_items[] = 'description=' . $description; $post_items[] = '00N4000000XXXX=' . "Shopping"; $post_items[] = '00N4000000xxxxxx=' . "1"; $post_items[] = 'external=1'; $post_items[] = 'lead_source=Shopping'; $post_string = implode ('&', $post_items); $ch = curl_init( 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8' ); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_exec($ch); // Post to Salesforce curl_close($ch); // close cURL resource }
Thank you for your help.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Limit Contact Form 7 hook (Before Send) to specific form’ is closed to new replies.