Skip to content

Instantly share code, notes, and snippets.

@benjaminpick
Last active September 8, 2015 06:44
Show Gist options
  • Save benjaminpick/32f3a1d58cc4681403c4 to your computer and use it in GitHub Desktop.
Save benjaminpick/32f3a1d58cc4681403c4 to your computer and use it in GitHub Desktop.
Contact Form 7: Special Mail Tag for POST data
<?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