When submitting a form to a WordPress site, there are a number of reserved keywords that should not be used as name attributes - including “name”, “author” and “type”. Using such keywords may result in odd errors - either unexplained 404 errors or the template reverting to the
The latter error looks particularly odd, because the permalink is unchanged. Debugging
$_REQUEST names in this context is not simple.
Most recently, when refactoring a project I managed to completely break form submission. The natural assumption is that there is a problem with your code. Eight hours of git resets and diffs later, I realized that I had set a form field with the name attribute “name” - coincidence can be a bitch.
Since I’ve cumulatively wasted a couple of days of my life on this issue, I’m documenting it here to prevent future nervous meltdowns.
Prefix all Form Names
A good general rule for WordPress forms is:
PREFIX FORM NAMES
I can personally attest that you need to avoid the string “name” as a name attribute (use “my_prefix_name” instead). The rest of the list is taken from the WordPress Codex:
There is a more extensive list here.
comments powered by Disqus