When a visitor fills out a form on the website, they enter:
- Address (Street, City, State, Zip Code)
I need to save this information to the database for future reference and I need to send an email to a central email address and to a specific email address, which changes depending upon the state of the visitor.
Basically, salespeople have territories and contacts from the website need to be sent to the main website email address as well as the person in charge of the territory.
Not all states have an assigned salesperson.
I installed Contact Form DB to save all submissions to the database.
I am using the method described on the Contact Form 7 website to select the recipient - Selectable Recipient with Pipes. I am using the state name as the selectable dropdown and the salesperson's email address following the pipe.
[select* state "Alabamafirstname.lastname@example.org" "Alaska" "Arizonaemail@example.com" "Arkansasfirstname.lastname@example.org" "Californiaemail@example.com" "Colorado" ]
I set up CF7's "Mail" to send to the website's central email address and to the salesperson's email address who operates in the selected state.
When a visitor selects a state that has an assigned salesperson, the salesperson's email address is entered into the database, not the state.
When a visitor selects a state name that does not have a designated salesperson, the state name is entered into the database, but no email is sent.
I also tried setting up "Mail" to send to
firstname.lastname@example.org and "Mail (2)" to send to
[state] (salesperson's email address), however no email was sent to
email@example.com when an email address was not provided for the state name in the dropdown.
Lastly, I tried entering the state name in this format -
"Alaska|". In this case, nothing was entered into the database for
state and no email was sent. I tested this using both of the "Mail" options listed above.
Now, I understand, I can simply enter
firstname.lastname@example.org for all state names without a designated salesperson - and that's fine.
The problem with this - the email address is still entered into the database for
I imagine I need a way to take the state name ([_raw_state]) and pass it into a hidden CF7 field, so it can be saved to the database, but I cannot seem to figure out how.