Hi @bevilleliam — You might take a look at Gravity or Contact Form to Email. I haven’t used the second one, but they both look like candidates for your use case.
Thank you for your reply Tara.
Gravity forms are deprecated and are untested with my WP theme.
Contact form to email does not have the feature of sending to a different email address depending on the selected “subject” from dropdown
I have my contact form with dropdown subject and I just need to Dynamically change recipient email
by hook into wpcf7_before_send_mail, get the submitted form data, find the enquiry-type dropdown option and then use an if/else statement to send the notifications to specific email addresses.
Below is the code I need help in finding where to place on my contact form…..
`// hook into wpcf7_before_send_mail
add_action( ‘wpcf7_before_send_mail’, ‘cf7dynamicnotifications’); // Hooking into wpcf7_before_send_mail
function cf7dynamicnotifications($contact_form) // Create our function to be used in the above hook
{
$submission = WPCF7_Submission::get_instance(); // Create instance of WPCF7_Submission class
$posted_data = $submission->get_posted_data(); // Get all of the submitted form data
/*
* Here are our ‘enquiry-type’ options and associated email address for reference
*
1 Bookings – rstskryne@gmail.com
2 Newsletters – therstnewsletter@gmail.com
4 default – admin@rstskryne.ie
*/
if( $posted_data[“enquiry-type”] == ‘Bookings’ ) { // If Bookings option is selected
$recipient_email = ‘rstskryne@gmail.com’;
}
elseif($posted_data[“enquiry-type”] == ‘Newsletters’) { // else if Newsletters option is selected
$recipient_email = ‘therstnewsletter@gmail.com’;
}
elseif($posted_data[“enquiry-type”] == ‘Jobs’) { // else if Jobs option is selected
$recipient_email = ‘jobs@frontendhero.dev’;
}
else { // If no dropdown option is selected
$recipient_email = ‘admin@rstskryne.ie’;
}
// set the email address to recipient
$mailProp = $contact_form->get_properties(‘mail’);
$mailProp[‘mail’][‘recipient’] = $recipient_email;
// update the form properties
$contact_form->set_properties(array(‘mail’ => $mailProp[‘mail’]));
}