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 5 years ago.
Improve this questionThe contact form 7 plugin provides an option to set the default value of a form field using a shortcode attribute (as documented here). This can be useful to dynamically change the recipient of a notification email using say a destination-email
field tag in a form and use a shortcode attribute to set its default value dynamically from within a page template using the do_shortcode
function. So for example, the following shortcode would send the email to [email protected] by default,
[contact-form-7 id="123" title="Contact Form" destination-email="[email protected]"]
However, it is not clear how to get it to work.
I already read other post where they were asking the same:
ACF + contact form 7
I must say that the solution didn't work for me. The contact-form keeps sending the emails to the email address set on Contact Form 7 configuration.
This is what i put on my single.php file:
<?php echo do_shortcode( '[contact-form-7 id="5" title="Form World Unite" destination-email="'.get_field( 'email' ).'"]' ); ?>
What could be wrong?
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 5 years ago.
Improve this questionThe contact form 7 plugin provides an option to set the default value of a form field using a shortcode attribute (as documented here). This can be useful to dynamically change the recipient of a notification email using say a destination-email
field tag in a form and use a shortcode attribute to set its default value dynamically from within a page template using the do_shortcode
function. So for example, the following shortcode would send the email to [email protected] by default,
[contact-form-7 id="123" title="Contact Form" destination-email="[email protected]"]
However, it is not clear how to get it to work.
I already read other post where they were asking the same:
ACF + contact form 7
I must say that the solution didn't work for me. The contact-form keeps sending the emails to the email address set on Contact Form 7 configuration.
This is what i put on my single.php file:
<?php echo do_shortcode( '[contact-form-7 id="5" title="Form World Unite" destination-email="'.get_field( 'email' ).'"]' ); ?>
What could be wrong?
Share Improve this question edited Dec 17, 2019 at 15:46 Aurovrata 1,34611 silver badges18 bronze badges asked May 2, 2019 at 12:07 Draws Ren GundamDraws Ren Gundam 251 gold badge2 silver badges6 bronze badges 5 |1 Answer
Reset to default 2the destination-email attribute requires an additional filter to be hooked to work, as detailed in cf7 doc and this forum thread, you need to ensure you do the following 4 steps:
1) in addition to the short code attribute,
[contact-form-7 id="123" title="Contact Form" destination-email="[email protected]"]
2) you need to,
add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 );
function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {
$my_attr = 'destination-email';
if ( isset( $atts[$my_attr] ) ) {
$out[$my_attr] = $atts[$my_attr];
}
return $out;
}`
3) which assumes you have a field in your form
[email* destination-email default:shortcode_attr]
//If you want this field hidden you can use this code instead:
[hidden destination-email default:shortcode_attr]
4) and last but not least you need to use the [destination-email]
mail tag in the 'To:' field in the mail configuration tab.
recipient=
notdestination-email=
. Or maybemail=
. But I'm not sure sorry. – Rup Commented May 2, 2019 at 13:05