“Send as Email (If…)”
If you have not discovered John Godley’s collection of WordPress plug-ins…you owe me big. I use at least half of them. The most flexible of them all is “Filled-In” – an amazing piece of code that alone is worth three any other plug-ins. Don’t take my word for it – check it out!
I have little doubt that some day Filled-in will be as popular among power users as widgets are among amateur bloggers.
The real beauty of it is that this baby can be easily extended.
And so, when I finally run into something it could not readily do, I wrote the extension posted below. I am not very good at PHP, but if you check my two posts on John’s site, you will see that it took me about four hours to figure out what it takes and put together (and debug) a new, useful extension.
You can do it too!
Ok, enough propaganda. Here it comes.
“Send as Email (If…)” extension
for the “Filled-In” plug-in for WordPress
Assumption: you have installed the original Filled-In plug-in and understand what it does.
What does this extension do?
It’s just one more Post Processor. It takes the input of a form processed by Filled-In, and hands it over to an email template to be sent to whoever you want.
This functionality is already implemented in the standard “Send as Email” PostProcessor.
What’s new? This extension only sends the email if a user-defined condition is satisfied. (For those who care: the condition part came straight from the “Is Equal” filter.)
How is this different from using a pre-processor?
A pre-processor, if not satisfied, kills your input right there and then. Form’s input is marked as “failed” and does not see the light of day.
Send as Email (If…) gives you a tool for emailing your form contents to various addresses depending on the input.
If it is not satisfied… nothing happens. Hopefully, some otherPostProcessor (another instance of Send as Email I, perhaps) will handle the data. Or not – your choice, your problem. (The transaction is marked as successful either way.)
Why did I write it? – an example of a possible use
I have a “Contact Us” form (not in this blog) with a drop-down subject list.
I wanted to route visitor input regarding Web Site problems to myself, while the rest would go elsewhere. All I had to do is define two PostProcessors:
- one takes all forms where “Subject” field is “Website problems” (see the screen shot: )and emails the contents to me
- the other takes all forms where “Subject” filed is not “Website problems” (there is a clever “not” checkbox) and emails the contents elsewhere.
You can be even fancier and have multiple overlapping sets of recipients with multiple different email templates – I told you, Filled-In kicks ass!
Download and install “Send as Email (If…) “
- Download Send as Email (If…) – email_if.txt
- Rename email_if.txt into email_if.php
- Upload email_if.php into your wordpress/wp-contents/plugins/filled-in/extensions/post/ directory. “Send as Email(If…) will now appear among your Filled-In Post Processors.
- Come back here and tell me how it works out for you! – writing this up took quite some effort.
- Go sand say “Thank You” to John for the Filled-In plug-in.
- NOW you are done.