Form redirecting to 404 on WordPress

Form redirecting to 404 on WordPress

I have just created a page with a form to talk to Eventbrite API and create a new ticket, but I was stunned when I found that the form was redirecting to a 404 page, even if the URL in the URL bar was correct.
<h2>It does not matter where you put your form</h2>
I researched a bit to see what the problem was and initially thought it was maybe the fact that I had put the form in a partial, a content-something.php file, could it be that it needs to be in a template? So I moved it higher up in single.php (in my case) but still nothing.
So I changed the action of my form and pointed it to a template file and created a page for it in the WordPress Admin. Still nothing…
<h2>The secret is in the name</h2>
Woke up this morning willing to look at this with a fresh pair of eyes and as you do the solution just landed on my screen (more on my search results list) – it’s amazing how you’re stuck on something one day, you call it a day, you start again in the morning and the solution comes so quickly…

So why was it not working? Don’t apply any crazy workaround and fiddle with .htaccess, the trick is just not to use the value “name” for any of your input fields name attribute!

&nbsp;

So instead of
<pre>&lt;input type=”text” name=”name” value=””&gt;</pre>
use
<pre>&lt;input type=”text” name=”myName” value=””&gt;</pre>
&nbsp;

I know, a bit weird, but it’s because WordPress has reserved that value. Also avoid using “day”, “month”, “year”, “hour”, “date” and “minute”.

Hope you found this quickly enough and that you have not wasted hours trying to work out what was wrong!

Tags:
No Comments

Post A Comment