[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 573
  • Last Modified:

WordPress Contact Form 7

Using this plugin, is there a way to determine the email address sent to dynamically based on the selection in a pulldown field?

For example, look at http://rain1.com/new-site/about-us/get-a-quote/. Note the pulldown called Estimate Type.

We want to send the email to different addresses, based upon the value selected fro this pulldown.

Is that possible with this plugin or do I need a more sophisticated one?

Thanks
0
Richard Korts
Asked:
Richard Korts
  • 12
  • 11
  • 3
2 Solutions
 
Jason C. LevineNo oneCommented:
You need a better plugin to do this.  Selecting recipients based on conditional logic is something that you usually find in the pro/paid plugins.  All of the good free ones (Contact Form 7, Ninja Forms, Formidable) can do a dynamic recipient assuming the email address is the value of the <select> box but chaining the recipient to another field's value appears to be reserved for the next level up. Contact Form 7 uses Pipes to do this:

http://contactform7.com/selectable-recipient-with-pipes/

Personally, I would use Gravity Forms for this but I have a developer's license for it so it's a sunk cost and it has more than paid for itself.  Formidable Pro is very affordable for a single site ($47) and rivals Gravity for usefulness, features, and support.  Ninja is the new kid on the block with an interesting business model - you buy modules as you need them - but to get it up to the level of Formidable or Gravity can get expensive.  It's the best of the breed for the free stuff, though.

One way to work around it is to send all quotes to a single email account and set up filters on that account to forward the message to the desired recipient based on the value.  That shouldn't be too tough to do.
0
 
Richard KortsAuthor Commented:
Jason,

I've never done the "filters" on an email account. Can you refer me to something that explains how to do that?

How do you pass the value to filter? With a query string attached to the jjones@xyz.com?

Thanks
0
 
Alicia St RoseOwner & Principle Developer/DesignerCommented:
This can be done with Contact Form 7.

You just have to add it to the select code with pipes "|":

Here's an example I'm using on a site. There are different departments for a festival:

[select* recipient class: recipient "Administrative Office | info@blahblah.com"  "Art Department | art@blahblah.com" "Music Coordinator | spektrum@blahblah.com" "Marketing Department | marketing@blahblah.com"  "Production | production@blahblah.com"  "Merch Vending | vending@blahblah.com" "Food Vending | food@blahblah.com" "Workshops and Villages | metatron@blahblah.com" ]

Looks like this on front end:

Contact Form 7 select with different email addresses.
Contact Form 7 isn't as easy as the Premium plugins but with some research you can do just about anything with it.

There is a copious amount of info on the Plugin site:

http://contactform7.com/
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
Jason C. LevineNo oneCommented:
I've never done the "filters" on an email account. Can you refer me to something that explains how to do that?

Depends on your email provider or email program.  In Gmail, you can set filters to look for anything in a message and then take an action based on that setting.  Thunderbird (email program) and Outlook both have something similar.

--------------------------------------

laughhearty,

But does that method show "Administrative Office" anywhere or just use the selected email as the recipeint?  I'm thinking that in this specific case, the same person may receive multiple types of estimate requests but the form doesn't also show the label from the select box, it would get confusing.

If each item in the select had a different recipient, then this would work fine.
0
 
Richard KortsAuthor Commented:
To laughhearty,

If this works, that is great & saves a LOT of effort.

If some of the items in the dropdown DO NOT have a piped to email, does it use the "general" email on specified in the "To" box?

Or if one has one, do all have to?

Thanks
0
 
Alicia St RoseOwner & Principle Developer/DesignerCommented:
@Jason C Levine
Each item in dropdown has unique email. And I'm not sure that the subject can be piped in. In the case of the Festival crew, they assumed that if they got the email, then the person wanted to talk with them and chose the correct department from dropdown. Piping the subject would be nice though.

@rkorts
It's my guess that if you don't pipe in a different email, the default will be used. Or just add the email in the To box. It may be redundant, but never hurts to be accurate.
Test it.
0
 
Alicia St RoseOwner & Principle Developer/DesignerCommented:
@rkorts make sure you change the "To: " recipient in the form.
0
 
Jason C. LevineNo oneCommented:
And I'm not sure that the subject can be piped in.

Got it. Not expecting it to be able to do that, would have been awesome for a free plugin though.
0
 
Richard KortsAuthor Commented:
To laughhearty,

The method you suggested has been tested; does not seem to work. Following is the select in the Contact Form 7:

[select* EstimateType include_blank "Drainage Installation | jeff@rain1.com, blair@rain1.com" "Drainage Repairs | jeff@rain1.com, blair@rain1.com" "&#91;Installation&#93; Residential Sprinkler System | jeff@rain1.com, blair@rain1.com" "&#91;Installation&#93; Commercial Sprinkler System | kris@rain1.com, blair@rain1.com" "&#123;Service&#125; Residential Sprinkler System | customerservice@rain1.com" "&#123;Service&#125; Commercial Sprinkler System | customerservice@rain1.com" "Lawn Rejuvenation | jeff@rain1.com, blair@rain1.com" "Water Treatment | jeff@rain1.com, blair@rain1.com" "Sump Pumps & Backups" "Well Pumps Repair & Service"]</p>

A test was sent with Drainage Installation selected. The email was sent to the To: list (NOT the selected emails after the pipe) and where the select item is to be displayed in the email it has Estimate Type: jeff@rain1.com, blair@rain1.com. (Namely tghe emails after the pipe)

Any ideas?
0
 
Jason C. LevineNo oneCommented:
Did you map this field (EstimateType) into the recipient field of your form?
0
 
Richard KortsAuthor Commented:
Jason C. Levine,

I don't know what this means "Did you map this field (EstimateType) into the recipient field of your form?"
0
 
Jason C. LevineNo oneCommented:
You've created a piped select field named EstimateType where the labels are the type of estimate and the values are email addresses.  In order for Contact Form 7 to send to that address, you have to put the field name tag in the To: section of the email template

[EstimateType]
0
 
Richard KortsAuthor Commented:
Jason C. Levine,

You mean like the attached?

Thanks
Contact-Form.jpg
0
 
Jason C. LevineNo oneCommented:
Yes, except delete the space in the tag since there is no space in the code in this comment:

http://www.experts-exchange.com/Web_Development/Blogs/WordPress/Q_28597768.html#a40558214

and then delete all of the email addresses following the closing bracket.
0
 
Richard KortsAuthor Commented:
Jason C. Levine,

OK, I see. What this implies is that every item in the pulldown HAS to have an email address indicated after it. No problem, but I just want to make sure.

Does it matter if there are spaces before & after the pipe character? Like "Drainage Installation | jjones@jmail.com". Should there be spaces or not?

Also, if there is more than one address associates with a specific item, should they be comma separated with or without a space? Like "jjones@gmail.com, ssmith@aol.com".
Or no space?

Thanks
0
 
Jason C. LevineNo oneCommented:
What this implies is that every item in the pulldown HAS to have an email address indicated after it.

Yes.

Does it matter if there are spaces before & after the pipe character? Like "Drainage Installation | jjones@jmail.com". Should there be spaces or not?

No idea (I don't actually use this plugin).  The documentation page I posted way above shows no spaces.  When in doubt, make your stuff look like the documentation.
0
 
Richard KortsAuthor Commented:
To all,

In testing this, I get the following email:

GET A QUOTE FORM via Rain One Website

////////////////////////////////////////////////////////////////

From:
Richard Korts

Address:
866 Chardonney Way
Escondido, [data:us_subdivisions.states data:us_subdivisions.districts] 92029

Email address:
richardkorts@gmail.com

Phone:
760-489-1780

Best Time to Contact:
11 AM

Estimate Type:
richardkorts@gmail.com

Describe Your Project:
Test sent to me

How How Heard About Us:
Neighbor

--
This e-mail was sent from a contact form on Rain One, Inc. (http://rain1.com/)

Note the "Estimate Type" is the email address AFTER the pipe (|) character for that item in the dropdown.

See attached; this is how the email body is now constructed.

How do I get the actual dropdown item to appear as "Estimate Type" instead of the email address?

Thanks
MessageBody.jpg
0
 
Jason C. LevineNo oneCommented:
How do I get the actual dropdown item to appear as "Estimate Type" instead of the email address?

You probably don't.  That's what I was talking about in my very first post as well as in response to laughhearty's suggestion:

laughhearty,

But does that method show "Administrative Office" anywhere or just use the selected email as the recipeint?  I'm thinking that in this specific case, the same person may receive multiple types of estimate requests but the form doesn't also show the label from the select box, it would get confusing.

http://www.experts-exchange.com/Web_Development/Blogs/WordPress/Q_28597768.html#a40554445

-------------------------------------------------

This is the limitation of a free plugin.  You can have a dropdown that changes the recipient but that value gets replicated anywhere else you use its template tag.  This plugin is not written in a way where where you can choose to show the label in one area and the value in another.  To be fair, the label attribute of selects, radios, and check boxes is usually not dealt with by any form system, be it plain old PHP or a WordPress plugin.  It's text used to mask the true value.
0
 
Richard KortsAuthor Commented:
I looked at the docs as you suggested. It says "To get the value before the pipe, use [_raw_elementname]"; I'm testing that now.

Rkorts
0
 
Richard KortsAuthor Commented:
FYI, I would LOVE to do the whole thing in good old php, but they don't want to pay. They invested too much already in the prior WordPress developer.
0
 
Richard KortsAuthor Commented:
To all,

The syntax [_raw_elementname] works.

However, my problem now is that if there are multiple email addresses for a specific item in the dropdown, it fails & gives this message:

Failed to send your message. Please try later or contact the administrator by another method.

I tried it with the names separated by a comma and by comma, space. Neither works.

Any ideas?
0
 
Jason C. LevineNo oneCommented:
According to the plugin author, it should work:

https://wordpress.org/support/topic/plugin-contact-form-7-selectable-recipient-with-pipes-sending-to-multiple-recipients

But that thread was several years and who knows how many patches ago.  Does it work when you don't use the rawelement tag?
0
 
Richard KortsAuthor Commented:
To Jason C. Levine,

Nope, same thing.

I'm starting to think it's time to dump this approach.

Or maybe set up mail groups on the server? Then have the email address like "group1@rain1.com", etc.

Thanks
0
 
Jason C. LevineNo oneCommented:
That's how I would have done it (or filters on the server looking by subject and then forwarding automatically).

On the other hand, I do have Gravity Forms so this would not have been an issue for me.
0
 
Richard KortsAuthor Commented:
A for effort; problem not solved.
0
 
Jason C. LevineNo oneCommented:
A for effort; problem not solved.

Begging to differ for the historical record.  I told you in my first post that a premium plugin is what was required for this and your experience bears that out.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 12
  • 11
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now