Reputation: 1566
I would like to be able to use any of the contact form 7 hooks and get the email body with all the shortcodes already parsed.
I know you can get the email body with something like this:
function example_func(){
$contactform = WPCF7_ContactForm::get_current();
// This would keep the email body with all the shortcodes
$mail_body = $contactform->prop('mail')['body'];
}
add_action('wpcf7_before_send_mail','example_func');
However, what I'm looking for is a way to get EXACTLY what I get on my email. That email body with all the shortcodes replaced by the form values.
Upvotes: 0
Views: 893
Reputation: 11
The wpcf7_mail_replace_tags() function should do the trick.
function example_func(){
$contactform = WPCF7_ContactForm::get_current();
$mail_body = $contactform->prop('mail')['body'];
$mail_body = wpcf7_mail_replace_tags( $mail_body );
}
add_action('wpcf7_before_send_mail','example_func');
Upvotes: 1