Wpcf7_before_send_mail



Oct 7th, 2016
  1. Wpcf7_before_send_mail
  2. Wpcf7_before_send_mail Hook
Never
Wpcf7_before_send_mail

So that’s pretty much it, creating a WordPress action hook to the wpcf7beforesendmail and understanding how to traverse the object should allow any midweight PHP developer to do pretty much anything with it. Senselock usb devices driver download for windows. Let’s see some examples, to use them get. Austin comments. Arnav did a great job - here is the finished code: // CONTACT FORM 7 removeallfilters ('wpcf7beforesendmail'); addaction( 'wpcf7beforesend. Now, in order to update a field from our form before the mail to be sent we will need to change the above function, because the cf7 data is saved before the wpcf7beforesendmail hook. Download oregon scientific driver. So we will use the following code: addfilter('wpcf7posteddata', 'saveapplicationform', 10, 1). Drivers pctv sound cards & media devices.

Not a member of Pastebin yet?Sign Up, it unlocks many cool features!
  1. add_action( 'wpcf7_before_send_mail', 'my_conversion' );
  2. $title = $contact_form->title;
  3. $posted_data = $submission->get_posted_data();
  4. $name = $posted_data['your-name'];
  5. $phone = $posted_data['tel-71'];
  6. $post_items[] = 'oid=00D4000000xxxxx';
  7. $post_items[] = 'last_name=' . $last;
  8. $post_items[] = 'email=' . $email;
  9. $post_items[] = 'description=' . $description;
  10. $post_items[] = '00N4000000xxxxxx=' . '1';
  11. $post_items[] = 'lead_source=Shopping';
  12. $post_string = implode ('&', $post_items);
  13. $ch = curl_init( 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8' );
  14. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
  15. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 );
  16. curl_exec($ch); // Post to Salesforce
  17. }
  18. add_action( 'wpcf7_before_send_mail', 'my_conversion' );
  19. $title = $contact_form->title;
  20. $posted_data = $submission->get_posted_data();
  21. $name = $posted_data['your-name'];
  22. $phone = $posted_data['tel-71'];
  23. $post_items[] = 'oid=00D4000000xxxxx';
  24. $post_items[] = 'last_name=' . $last;
  25. $post_items[] = 'email=' . $email;
  26. $post_items[] = 'description=' . $description;
  27. $post_items[] = '00N4000000xxxxxx=' . '1';
  28. $post_items[] = 'lead_source=Shopping';
  29. $post_string = implode ('&', $post_items);
  30. $ch = curl_init('https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8' );
  31. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
  32. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 );
  33. curl_exec($ch); // Post to Salesforce
  34. }
RAW Paste Data
WordPress plugin - Contact Form 7 (wpcf7) snippets
wpcf7-before-send-mail.php
Wpcf7_before_send_mail
<?php
/**
* Modify the email before send.
*/
functionwpcf7_before_send_mail($WPCF7_ContactForm) {
$properties = $WPCF7_ContactForm->get_properties();
$recipients_list = [
1 => 'ABC1 <abc1@example.tld>',
2 => 'ABC2 <abc2@example.tld>',
];
// Update recipients:
if (isset($recipients_list[$_POST['recipient']])) {
$properties['mail']['recipient'] = $recipients_list[$_POST['recipient']];
}
$WPCF7_ContactForm->set_properties($properties);
}
add_filter( 'wpcf7_before_send_mail', 'wpcf7_before_send_mail' );
wpcf7-notes.php
<?php
if (isset($_POST['_wpcf7'])) {
$ok_msg = '{'mailSent':true,'into':'#'. $_POST['_wpcf7_unit_tag'] .','captcha':null,'message':'%s'}';
$error_msg = '{'mailSent':false,'into':'#'. $_POST['_wpcf7_unit_tag'] .','captcha':null,'message':'%s','invalids':[]}';
// exit(sprintf($ok_msg, 'Thank you for your message.'));
// or
// exit(sprintf($error_msg, 'There was an error, please try later.'));
}

Wpcf7_before_send_mail

wpcf7-validate.php
<?php
/**
* Validate fields.
* @see http://hookr.io/filters/wpcf7_validate_type/
*/
functionwpcf7_validate( $result, $tag )
{
$tag = newWPCF7_Shortcode( $tag );
if ( 'email'$tag->name ) {
if ( filter_input(INPUT_POST, $tag->name, FILTER_VALIDATE_EMAIL) false ) {
$result->invalidate( $tag, 'The email is not valid.' );
}
}
if ( 'zipcode'$tag->name ) {
if ( filter_input(INPUT_POST, $tag->name, FILTER_VALIDATE_REGEXP, ['options'=>['regexp'=>'#^d{5}$#']]) false ) {
$result->invalidate( $tag, 'The Zip Code is not valid.' );
}
}
// Define: reCAPTCHA_KEY and reCAPTCHA_SECRET_KEY
if ( 'captcha'$tag->name ) {
require_once'utils/lib/recaptcha.php';
$recaptcha = new reCaptcha(reCAPTCHA_KEY, reCAPTCHA_SECRET_KEY);
$validate = $recaptcha->validateResponse();
if (null$validate) {
$result->invalidate( $tag, 'The captcha field is empty.' );
} elseif (false$validate) {
$result->invalidate( $tag, 'The captcha field is not valid.' );
}
}
if ( 'phone'$tag->name ) {
if ( filter_input(INPUT_POST, $tag->name, FILTER_VALIDATE_REGEXP, ['options'=>['regexp'=>'#^(?d{3})?[s-]?d{3}[s-]?d{4}$#']]) false ) {
$result->invalidate( $tag, 'The phone is not valid.' );
}
}
return$result;
}
add_filter( 'wpcf7_validate_text*', 'wpcf7_validate', 20, 2 );

Wpcf7_before_send_mail Hook

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment