Selectable Recipient with Pipes

Imagine that you are a webmaster of a company and you need a contact form on your site which will allow the sender to select an email recipient. Let’s say that the options are the CEO of the company (, the sales department ( and the support department (

You’ve been able to achieve this with Contact Form 7 in this way: first, make a drop-down menu or radio button for the selection (you can do this by inserting a form tag such as:

[select your-recipient ""

into the form template); second, enter a corresponding mail tag [your-recipient] into the To: field in the Mail section. This ensures that the email is sent to the specific address that the sender selected.

However, there has been a problem with this. By using this procedure, the email addresses are revealed over the Internet and this is not good. These addresses could then become targets of evil spammers very quickly.

So, what you need is a way to allow senders to select from closed data safely. The pipe (‘|’) support is just for this very purpose.

Change the form tag of drop-down menu to:

[select your-recipient "CEO|"

If you insert a pipe (‘|’) character in the middle of the option value, only the part before the pipe will be open to the outside, and the part after the pipe will be used for mail replacement.

pipe sample

To get the value after pipe character, put the usual mail tag corresponding to the form tag ([your-recipient] in the case of the above example) in the Mail templates. To get value before pipe, you can use [_raw_{field name}] ([_raw_your-recipient] in the case of the above example).

You can use this usage of pipe only in the drop-down menu values, radio buttons or checkboxes. If you don’t like this feature, you may define the constant WPCF7_USE_PIPE as false to disable it.

Just another contact form plugin for WordPress. Simple but flexible.

%d bloggers like this: