I have a form:

<form name="customer_details" method="POST" onsubmit="return form_validation()"

I placed the PHP file in my theme folder, but WordPress gives me an error:

404 — Fancy meeting you here!


Add unique field in your form.

Eg: <input type="hidden" name="wdm_action" value="1">

Put your 'customer-details.php' file code in below function:-

//check if that field present in the form, if yes then perform the action
if(isset($_POST['wdm_action'] && $_POST['wdm_action'] != ''){
    //customer-details.php file code


You can just define an action method in function file and leave form action blank.

Use hook init by

function formaction() {
    if($_post['submit']=='1') {
        //form submit code here 

1 You need to change the form action and easiest way to do is creat a page with name like "x form action" (slug xaction). Now publish it and create a page template for this page like "page-xaction.php".

For know more about creating page template read this.

2 Now change the form action like this:

echo esc_url(get_permalink(100));

Please note 100 is the ID of the page you have created "x form action".

Now you are good to write your form action code in the file page-xaction.php

Also read about wp_nonce here


You should change this (if you dont use that php file directly, like example.com/customer-details.php`):




instead, you should use that as page template, then change to:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.