Hi again,
Over here #363255: Using "Additional Validation" for complex conditional recipients? I learned to use Additional Processing and set up the following:

  • Conditional recipient based on (hidden) field 'email_address_send'
  • Some PHP in Additional Processing that looks at a bunch of other values and resets the value of 'email_address_send' according a zip code entered elsewhere in the form
  • 'email_address_send' has a default value so that if none of the zipcodes match, the email still reaches someone

When I submit my form, the values all look correct -- in the database the email_address_send field shows the correct value (reset to match the zip). But the actual email is being sent to the default address, instead of the one set by Additional Processing.

I'm not sure where to start looking for a fix, since the default address never shows up in the final entry. Do the notification emails get sent before the Additional Processing field is parsed?

Thanks for any thoughts!

Comments

leenwebb’s picture

Status: Active » Closed (fixed)

Ah! It seems that given enough time and apple pie I am capable of solving my own problems. Who knew!

So in that Additional Processing field, I changed the following values:

$form_values['submitted'][4] = $new_custom_email_address;
$form_values['submitted_tree']['email_address_send'] = $new_custom_email_address;

And that saved the correct value in the form submission but did not result in the notification being sent to that address. To make that happen, I also had to change this value:

 $node->webform['additional_emails'][4] = $new_custom_email_address;

And now is all hunky-dory! The new address is saved the database, and said address also receives the email notification about the form submission. (If anyone else is doing the same thing: you could also add a whole new value to $node->webform['additional_emails'] and the code is clever enough to know to send an email to each address in the array.)