Sure, here’s some example code:
function my_special_mail_tag( $output, $name, $html ) {
if ( 'my_surrogate_shortcode' == $name )
$output = do_shortcode( '[real_shortcode attribute="value"]' );
return $output;
}
add_filter( 'wpcf7_special_mail_tags', 'my_special_mail_tag', 10, 3 );
When you enter [my_surrogate_shortcode]
into your email template, the real shortcode [real_shortcode attribute="value"]
is executed instead, and the result is printed in the email.
You can either add this code to your functions.php
(if you use a child theme), or in a custom plugin like this (prepared for multiple shortcodes as an example).
<?php
/**
* Plugin Name: My custom shortcodes for Contact Form 7
*/
function my_special_mail_tag( $output, $name, $html ) {
if ( 'my_surrogate_shortcode' == $name )
$output = do_shortcode( '[real_shortcode attribute="value"]' );
if ( 'my_other_surrogate_shortcode' == $name )
$output = do_shortcode( '[other_real_shortcode]' );
return $output;
}
add_filter( 'wpcf7_special_mail_tags', 'my_special_mail_tag', 10, 3 );