I want to submit a form to another PHP file which lays in the same folder:


The form action attribute looks like this:

<form name="lookat" type="submit" action="my-plugin-folder/file.php">

However, if I click on the submit button, I get redirected to:


How can I get rid of wp-admin and access the file in my-plugin-directory?

  • Is your form located in the admin section or on the front end? Also, is there a reason you want to POST to that specific file instead of using one of the WordPress provided hooks? Commented Sep 10, 2015 at 23:24
  • Yes, the form is located in the admin section. I want to link to that file because it contains the html for a table which should Display data depending on the form
    – neilos
    Commented Sep 10, 2015 at 23:46

1 Answer 1


You should not try to do it. Direct access of php files which are not in the root directory might be blocked for security reasons.

what you need to do is register a settings page for your plugin and add into your forms some hidden field that indicates what kind of processing you want to do on the $_POSTed data. Then use the URL of the settings pag as the action url for the form (use admin_url to calculate it).

Side note: always try to avoid relative urls in wordpress forms. It is too easy to end up with the form at a place where the relative url points to nothing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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