Skip to content
Advertisement

Dynamic Email Recipient based on ZIP Code Input for Contact Form 7

We have 4 Offices with many assigned ZIP Codes:

  • 21079, 22085,…. = Hamburg
  • 10115, 10178,…. = Berlin
  • 60306, 60312,…. = Frankfurt
  • …..,……,…. = Munich
  • everything else = Head Office

Is it possible to read out the ZIP Code Input from the Form and send the Mail to the assigned Office dynamically?

It has to be dynamically without a dropdown (on Front End) of all ZIP Codes or Cities.

I tried this without success

JavaScript

EDIT

Thank you for your help. My solution works well, I had problems with my email provider.

Do you know how I can extend the value? I would like to instert more than one value.

For example:

if ( ‘21079’, ‘21080’, ‘21081’ === $posted_data[‘plz’] ) { $recipient_email = ‘office1@xyz.com’;

This gives me an syntax Error.

Also this didnt worked:

if ( ‘21079’ || ‘21080’ || ‘21081’ === $posted_data[‘plz’] ) { $recipient_email = ‘office1@xyz.com’;

Advertisement

Answer

Your question was almost correct. The set_properties() needs to pass the whole array (in your case) $mailProp.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement