Dynamic Email Recipient Not Working
-
I had a bit of code working a while back that would dynamically change who would receive the email based on what city was filled out in the form. But right now it is defaulting to the if, and skipping the else entirely. So now all emails are going to abc@xyz.com regardless of city. Any ideas what I’m doing wrong here? I’m new to PHP.
// 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 if( $posted_data["property-City"] == 'denver' or 'Denver' or 'arvada' or 'Arvada' or 'wheat ridge' or 'Wheat Ridge' or 'aurora' or 'Aurora' or 'parker'or 'Parker' or 'cherry creek' or 'Cherry Creek' or 'greenwood village' or 'Greenwood Village' or 'centennial' or 'Centennial' or 'thornton' or 'Thornton' or 'northglenn' or 'Northglenn' or 'commerce city' or 'Commerce City' ) { // If General option is selected $recipient_email = 'abc@xyz.com'; } else { // If no dropdown option is selected $recipient_email = 'efg@xyz.com'; } // 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'])); }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Dynamic Email Recipient Not Working’ is closed to new replies.