Last active
October 10, 2016 13:06
-
-
Save tcdevs/d9e68a9b808fea80cacda0d894084267 to your computer and use it in GitHub Desktop.
Replace form fields by name with uppercase characters - WP Contactform 7
This file contains hidden or 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
<?PHP add_action( 'wpcf7_before_send_mail', 'wpcf7_add_text_to_mail_body' ); | |
function wpcf7_add_text_to_mail_body($contact_form){ | |
$submission = WPCF7_Submission::get_instance(); | |
if ( $submission ) { | |
// Get POST data | |
$posted_data = $submission->get_posted_data(); | |
// get mail property | |
$mail = $contact_form->prop( 'mail' ); // returns array | |
// add content to email body | |
$mail['body'] .= ' - ' . implode(", ", $posted_data); | |
// Replace exsisting content | |
$mail['body'] = str_replace('[your-name]', strtoupper($posted_data['your-name']), $mail['body']); | |
} | |
// set mail property with changed value(s) | |
$contact_form->set_properties( array( 'mail' => $mail ) ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment