About a week ago I was contacted through my WordPress Google Form Support and Help form by a user of my WordPress Google Form plugin. The symptoms he described sounded very much like the problem I recently chased down with ModSecurity. I figured this must be another use model that I hadn’t accounted for.
Fortunately and unfortunately, I was wrong. After going through the usual process of trying to narrow down the problem (using wpGForm debug mode, disabling all plugins, etc.), we were able to isolate the problem to what I suspected was a theme issue. Ugh. A lot of times people don’t want to or can’t change their theme. I wanted to swap the theme for TwentyTen or TwentyEleven but that wasn’t really possible as the site is live and being used.
Now what? Since the user couldn’t switch the theme and we ended up putting a copy of his theme in a development area and were able to replicate the problem. Whew – the helped a lot. I could switch back and forth between his theme and TwentyTen in debug mode and compare the results.
It took a while to track it down but it turns out the theme, Unite from Paralleus, has a jQuery script which scans the page content for Submit Buttons, removes the buttons, and rebuilds them to match the theme style. In theory this is actually rather clever and makes the submit buttons attractive although I am not sure why it couldn’t be done with CSS classes, I didn’t look at it closely enough. However, in practice when the submit buttons are reconstructed, they don’t contain all of the attributes they started with so they are not equivalent. And this matters when submitting a Google form. A lot.
A Google form just can’t be submitted with a submit button. It needs to be submitted with the submit action having a named parameter and a value. Google uses the named parameter and it’s value to support multi-page Google forms. It is this named parameter and value that Unite strips off effectively making the form incomplete which causes Google to rejects it as an incomplete form. Because Google rejects it, WordPress Google Form simply redisplays the form again. To the end user it looks like the form was never submitted.
As a plugin developer, I am not sure what the right answer is here. Actually, that isn’t true. I do know the right answer is. The theme should be fixed but I have zero control and influence over that happening. To solve the problem in the short term, I have created a hack of sorts that works around this problem with the Unite theme but that is in a one-off build for testing. What should I do to my plugin? Add a unitethemehack=’on’ attribute? Right now that is probably the best option although it feels pretty dirty. The code to enable this hack is trivial because Unite won’t muck with submit buttons which have the noStyle CSS class applied to them. At least there is a work-around. The hack I added to WordPress Google Form is inserting class=”noStyle” to any submit button in the Google Form HTML.
But I am wondering how many more scenarios like this will I run into? Is there a more general purpose solution? Probably. I’ve been thinking about a “find and replace” solution as I was asked about doing something similar previously to rename all of the submit buttons as something else. I’ll keep noodling but for the time being, I think I’m going forward with a new attribute.