marcelograciano
Forum Replies Created
Viewing 4 replies - 1 through 4 (of 4 total)
-
Forum: Plugins
In reply to: [Contact Form 7] Limit Contact Form 7 hook (Before Send) to specific formHello. I got a solution, I do not think it’s the best but here is what I did:
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(); } if ( 'FORM NAME' == $title ) { $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 }
I used the solution suggested by @takayukister. In case “$contact_form->title()”.
Just remember to change “FORM NAME” with the name of the form that you want to perform the action.
Thanks again @takayukister!
- This reply was modified 8 years, 4 months ago by marcelograciano.
Forum: Plugins
In reply to: [Contact Form 7] Limit Contact Form 7 hook (Before Send) to specific formI did like this:
add_action( 'wpcf7_before_send_mail', 'my_conversion' ); function my_conversion( $contact_form ) { $title = $contact_form->title; $submission = WPCF7_Submission::get_instance(); $id = $contact_form->id(); if ( $id==68 ) { $submission->skip_mail = true; } if ( $id==65 ) { $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-244"]; $description = $posted_data["your-message"]; $post_items[] = 'oid=00D41000000dC7r'; $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[] = 'external=1'; $post_items[] = 'lead_source=Radikal'; $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 }
Now the form of ID = 65 normally recorded in Salesforce. But the ID = 68 does not send the email, is locked with the fields filled. What am I doing wrong? Does anyone have any ideas?
Thanks.
Forum: Plugins
In reply to: [Contact Form 7] Limit Contact Form 7 hook (Before Send) to specific formThank you for the tip. I had found this function:
if ( $contact_form->id !== $myform_id ) return;
But I know very little about PHP. Where should I enter this line? Would you help me?
Thanks again.
Forum: Installing WordPress
In reply to: /wordpress/wp-admin/install.php?step=2 Error.I have the same problem, Do you can resolve? How? Thanks a lot.
Viewing 4 replies - 1 through 4 (of 4 total)