Last active
September 8, 2015 06:44
-
-
Save benjaminpick/32f3a1d58cc4681403c4 to your computer and use it in GitHub Desktop.
Contact Form 7: Special Mail Tag for POST data
This file contains 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 | |
/** | |
* Verwendung: Im Email-Template können nun auch POST-Daten versendet werden, die nicht über einen WPCF7-Shortcode, sondern über HTML im Formular eingefügt wurden. | |
* <input type="date" name="special" /> | |
* [post_special] | |
*/ | |
add_filter('wpcf7_special_mail_tags', 'yt_wpcf7_mail_tags', 10, 3); | |
function yt_wpcf7_mail_tags($output, $tagname, $is_html) { | |
if ($tagname{0} != 'p' || strpos($tagname, 'post_') !== 0) | |
return $output; | |
$key = substr($tagname, 5); | |
if (isset($_POST[$key])) | |
$output .= $_POST[$key]; | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment