Wufoo is a neat little service that lets you create and manage webforms. This is not a paid guerilla advertisement, by the way. I don’t want to have to deal with form processing, and found out about Wufoo after a little bit of research. One of the selling points for me is that they have an API, so while they handle the grunt work of saving form data, I can have complete control over the look of my forms.
I found out someone had already developed a method for integrating a WordPress site with Wufoo’s API (Side note: the guys over at Phuse have a great blog, I recommend reading it). To make my life easier, I built a WordPress plugin based on their strategies.
The plugin itself contains most of the same ideas outlined in the article above. If you didn’t read it, the basic workflow is
- Set up a WordPress AJAX action hook
- Use jQuery to POST to the AJAX action hook
- Sanitize the inputs using Wufoo’s API classes
- Set up an API call with a given API key, Wufoo ID, and form hash
- Send a JSON response back to the frontend client
If you only have one form to work with, the solution in Phuse’s article is perfect. But for me, since I was planning on having three forms on my site, I needed a slightly more robust solution. Each API call requires a Wufoo form’s unique hash ID, so I began by setting up an array of hashes, that were keyed to a specific purpose (e.g. “contact-form”). I thought it would be nice to be able to manage form hashes from the admin panel and made the decision to build a plugin.
It was fairly trivial to take Phuse’s workflow and wrap it up into a PHP class. Using WP’s
enqueue_scripts hooks, it was also easy to inject the jQuery snippet into the frontend of the site for easy processing. (By the way, I did disclose to them that a majority of the plugin is code taken directly from their article.)
All I really did was create a section in the WordPress backend that allows site admins to enter Wufoo API information. Then, they can let the Plugin worry about the API negotiation and sending. My early use of the plugin has been promising.
But, it’s still a fairly young project and hasn’t really been put to serious use. Using the plugin in production could be a risky proposition, so keep that in mind. If you find a bug, please fill out an issue on Github and I’ll look into patching it.