Currently I am facing a problem to overwrite the body content of the mail_2
in the hook wpcf7_before_send_mail
.
I am trying to rewrite a wpcf7 shortcode to a more proper presentation of the content with some html modifications.
The problem is that I can't overwrite the mail body. After I rewrite the body and print directly the result it seems to be back as the default body. When I print my modification directly, I see the modifications as I want them to be.
Example of code:
add_action("wpcf7_before_send_mail", "cf7_wpcf7_custom", 99, 1);
# Before sending email
function cf7_wpcf7_custom($properties, $contact_form_obj) {
$submission = WPCF7_Submission::get_instance();
$wpcf7 = WPCF7_ContactForm::get_current();
$wpcf7->mail_2['body'] = str_replace('[checkbox-1]', '..test..', $wpcf7->mail_2['body']);
// No changes appearing
var_dump($wpcf7->mail_2['body']);
exit;
}