To clarify I don’t expect anybody to give me a copy and paste solution, I just need help finding what file is responsible for the processing of the tags and sending the email 🙂
CF7 defines action hooks so that you can extend CF7 rather than modify it. I’d always go that route to avoid having to re-apply my customisation after every update.
The CF7 action I use for this is called wpcf7_before_send_mail.
In my application, the form user enters a reference which I then use to look up the email address I need from the database, just before the email is sent.
To achieve this I have a placeholder To: address in the form, and a wpcf7_before_send_mail action that does the query and replacement.
Here’s how the action is defined:
// My CF7 action
//
function wpcf7_set_email_address($contact_form) {
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
...
// 1. Get reference from submitted form
// 2. Use reference to query database for actual email address
// 3. Replace placeholder email address with the correct one from DB
...
}
}
}
add_action("wpcf7_before_send_mail", "wpcf7_set_email_address");
See the CF7 doc for how to access what you need inside the action from the $submission and $contact_form objects.
You have a choice of where to put your action code so that it will be loaded at the right time. Mine is in a very small custom plugin of my own, but you could also put it in the functions.php file of your theme. If you go the theme route, it’s still best to use a child theme, even if this is your only customisation, to avoid re-applying your code after updates.
Hope this helps.
-
This reply was modified 8 years, 3 months ago by
dcurley. Reason: formatting code
Thank you very much dcurley! 🙂