Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1129441
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 11 months ago.
Improve this questionI have added the short-code in my Contact Form 7 Message Body but it is not working.
function.php
function wpb_demo_shortcode() {
$output = '<p style="font-size:11pt;font-family:Calibri,sans-serif;margin:0;">Lets stay connected!</p>';
return $output;
}
// register shortcode
add_shortcode('greeting', 'wpb_demo_shortcode');
/**
* A tag to be used in "Mail" section so the user receives the special tag
* [greeting]
*/
add_filter('wpcf7_special_mail_tags', 'wpcf7_tag_tournament', 10, 3);
function wpcf7_tag_tournament($output, $name, $html)
{
$name = preg_replace('/^wpcf7\./', '_', $name); // for back-compat
$submission = WPCF7_Submission::get_instance();
if (! $submission) {
return $output;
}
if ('greeting' == $name) {
return $submission->get_posted_data("greeting");
}
return $output;
}
// Other Code
add_filter( 'wpcf7_form_elements', 'mycustom_wpcf7_form_elements' );
function mycustom_wpcf7_form_elements( $form ) {
$form = do_shortcode( $form );
return $form;
}
I have added this code in my functions.php
but my shortcode is not showing html in the email.
Added this in the Message Body: [greeting]
Any help is much appreciated.
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 11 months ago.
Improve this questionI have added the short-code in my Contact Form 7 Message Body but it is not working.
function.php
function wpb_demo_shortcode() {
$output = '<p style="font-size:11pt;font-family:Calibri,sans-serif;margin:0;">Lets stay connected!</p>';
return $output;
}
// register shortcode
add_shortcode('greeting', 'wpb_demo_shortcode');
/**
* A tag to be used in "Mail" section so the user receives the special tag
* [greeting]
*/
add_filter('wpcf7_special_mail_tags', 'wpcf7_tag_tournament', 10, 3);
function wpcf7_tag_tournament($output, $name, $html)
{
$name = preg_replace('/^wpcf7\./', '_', $name); // for back-compat
$submission = WPCF7_Submission::get_instance();
if (! $submission) {
return $output;
}
if ('greeting' == $name) {
return $submission->get_posted_data("greeting");
}
return $output;
}
// Other Code
add_filter( 'wpcf7_form_elements', 'mycustom_wpcf7_form_elements' );
function mycustom_wpcf7_form_elements( $form ) {
$form = do_shortcode( $form );
return $form;
}
I have added this code in my functions.php
but my shortcode is not showing html in the email.
Added this in the Message Body: [greeting]
Any help is much appreciated.
Share Improve this question asked Feb 26, 2020 at 14:49 Rahul KumarRahul Kumar 2074 silver badges20 bronze badges 2 |1 Answer
Reset to default 2You can place only the following code in functions.php and it will work:
// Activate Shortcode Execution for Contact Form 7
add_filter( 'wpcf7_form_elements', 'do_shortcode' );
本文标签: My shortcode is not working in Contact Form 7 Message Body
版权声明:本文标题:My shortcode is not working in Contact Form 7 Message Body 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736729913a1949933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
echo do_shortcode('[greeting]')
to try to force WP to parse it. – WebElaine Commented Feb 26, 2020 at 15:17