0

I'm using Contact Form 7 with an ACF field.

In ACF, I created an email field : email.

In my Contact Form 7, I have a field called destination-email:
[email* destination-email id:exp-email default:shortcode_attr]

In my template file i have a line :

<?php echo do_shortcode( '[contact-form-7 id="983" title="Formulaire de contact 1" destination-email="[email protected]"]' ); ?>

I need to replace "[email protected]" with the value of the ACF field email.

How can I do it?

3

2 Answers 2

2

You can use php values inside the do_shortcode function In your case it will be like this:

<?php echo do_shortcode( '[contact-form-7 id="983" title="Formulaire de contact 1" destination-email="'.get_field( 'email' ).'"]' ); ?>
0
0

In addition, the field can be populated with the help of post meta

[email* destination-email id:exp-email default:default:post_meta ]

destination-email = ACF field id. instead of email, a hidden field can be used. (in case it is being used just for fetching recipient email address.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.