Skip to content
Advertisement

How can I add a dynamic value to the Contact Form 7 Plugin?

How can I add a dynamic value to Contact Form 7 without using an extra plugin. I need to display the Post title in the emails sent.

I am using the example in the Contact Form 7 docs here, but the clock tag only shows in the form page and not in the emails sent.

I don’t know if there is something missing, or if I should add anything else to make this work?

add_action( 'wpcf7_init', 'custom_add_form_tag_clock' );

function custom_add_form_tag_clock() {
   wpcf7_add_form_tag( 'clock', 'custom_clock_form_tag_handler' ); // "clock" is the type of the form-tag
}

function custom_clock_form_tag_handler( $tag ) {
   return date_i18n( get_option( 'time_format' ) );
}

Advertisement

Answer

I’ve found the answer in the contact form 7 documentation https://contactform7.com/special-mail-tags/

I’ve added the special mail tag [_post_title] in the message body that is sent by contact form 7, and that solved my problem.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement