One of our clients at work had an issue with duplicate submissions on a survey powered through Gravity Forms. The survey was distributed to classrooms full of click-hungry grade school children where dozens of students would be submitting the survey at the same time. The surveys didn’t collect any personally-identifiable information that we could use to set up a uniqueness rule on, so eliminating duplicate entries was a largely manual task.
We abstracted and open-sourced our solution in the form of a WordPress plugin simply named Gravity Forms Duplicate Prevention. The plugin prevents duplicate submissions in two ways: first, a small bit of JavaScript is loaded into the page that disables the submit button(s) on form submit. Second, the plugin creates a cryptographic hash of the form data upon submission. This unique hash is compared to a hash stored in a PHP session (if available) and, if a matching hash is found, the form data is altered to simulate a failing honeypot (a trap for spammers using automatic form submitting scripts) condition. Like with all failed honeypots, Gravity Forms will skip saving the data or sending any notifications but the form will appear (to the user) to have been submitted successfully.
Comments are closed.