Easily send to a recipient based on a drop-down choice
A staple plugin I have used over the years with WordPress has been Contact Form 7. It’s a basic form plugin but it is highly customisable by adding your own CSS styling. One of the things I needed to do for a site was to make sure an email was delivered to different recipients depending on the location the user selects. For example, I needed the user to select an option from the drop-down menu. Depending on which location they selected this was where the email would go.
Let’s set up the Contact Form 7 form:
- Create your contact form with the regular tags eg: Name, Phone, Email etc..
- Create a tag field – [select* recipient]
This tag field works the same as a [select menu] it creates a drop-down menu. I have placed an asterisk in this field to make the field required.
- Add items to your list. eg: [select* recipient “Paris” “Rome” “London”]
These could be store locations, departments in a company, business locations etc.
- Now we need to adjust this list to include the email addresses after each location. You need to add a “|” (pipe) between each location. This hides the email address from the user but tells contact form 7 where the email should go. eg: [select* recipient “Parisemail@example.com” “Romefirstname.lastname@example.org” “Londonemail@example.com”]
- Now to fill out your mail fields. Update the to: field in the mail section. Add the word [recipient]. This will now send the mail to whomever the user selects from the drop-down list.
- I also added in my message body a line to show who the email was intended for. Selected Recipient: [recipient]. This will now show the email address in the message body.
Simple, easy and effective 🙂
If you want to use this plugin yourself on your WordPress site you can find it here: Download Contact Form 7