I have contact form on my website. And I need to change the value of one field before sending mail. For example name
. I try like this:
function contactform7_before_send_mail( $cf7 ) {
$cf7->posted_data['your_name'] = 'John Doe';
}
add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' );
But in the email comes the value that is specified in the form.
Recently faced the same problem.
There is a field in this form called “[s2-name]” for example. When a visitor submit out a form, I want to get this field, then change and send. After some information searching, I wrote this code:
Tested with: WP 5.4.2 and Contact Form 7 Version 5.2
Try this:
post.php
form.html