title: Form action WordPress Plugin
body: <p>I am creating a specialized WordPress plugin, and its not for use outside of this singular case for the rest of the question we will refer to the wordpress plugin folder as plug-folder. Inside the plug-folder I have multiple files, a file named form_submit.php and a file named form_template.php. form_template.php is registered as a page template that can be applied to any post or page through the WordPress dashboard. The issue is because the form_submit.php file is inside the plugin folder how do I map my form action to post the data to the file? Simply listing it as</p>
  
  <pre><code>&lt;form action="form_submit.php" method="post" &gt;
  </code></pre>
  
  <p>Will not work as I need because it will be looking for the form_submit.php in the root directory of the site not the plugin folder and trying to map out the URL scheme for it in the plugin folder like</p>
  
  <pre><code>&lt;form action="wp-content/plugins/plug-folder/form_submit.php" method="post" &gt;
  </code></pre>
  
  <p>Doesn't work either, does a method exist that I am not thinking of?</p>
  
  <p>Edit: After switching to use plugins_url() as suggested its working in one of the two instances where I am using forms. My register form (attached below) is not working, comes back error loading page.</p>
  
  <pre><code>&lt;form action="&lt;?php echo plugins_url( 'register_submit.php', __FILE__ ); ?&gt;" method="post" autocomplete="off"&gt;
  
                              &lt;?php if($_GET['error'] == 'username'){ ?&gt;
                                  &lt;div class="error_message"&gt;
                                      Uh oh! That username is already taken.
                                  &lt;/div&gt;
                              &lt;?php }else if($_GET['error'] == 'email'){ ?&gt;
                                  &lt;div class="error_message"&gt;
                                      Uh oh! That email is already in use.
                                  &lt;/div&gt;
                              &lt;?php }else if($_GET['error'] == 'email_invalid'){ ?&gt;
                                  &lt;div class="error_message"&gt;
                                      Uh oh! Make sure to enter a valid email.
                                  &lt;/div&gt;
                              &lt;?php }else if($_GET['error'] == 'signup_blank'){ ?&gt;
                                  &lt;div class="error_message"&gt;
                                      Uh oh! Make sure to fill in all the fields.
                                  &lt;/div&gt;
                              &lt;?php } ?&gt;
  
  
                              &lt;input type="text" name="first_name" class="signup_input" id="first_name_input" placeholder="First Name" value="&lt;?= $_GET['first_name']; ?&gt;" required&gt;
  
                              &lt;input type="text" name="last_name" class="signup_input" id="last_name_input" placeholder="Last Name" value="&lt;?= $_GET['last_name']; ?&gt;" required&gt;
  
                              &lt;input type="text" name="email" class="signup_input" placeholder="Email" value="&lt;?= $_GET['email']; ?&gt;" required&gt;
  
                              &lt;input type="password" name="password" class="signup_input" placeholder="Password" required&gt;
  
                              &lt;input type="radio" name="gender" value="Female" required&gt; &lt;font color="#FFF"&gt;Female&lt;/font&gt; &amp;nbsp;
                              &lt;input type="radio" name="gender" value="Male" required&gt; &lt;font color="#FFF"&gt;Male &lt;/font&gt;
  
                              &lt;input type="submit" name="submit" class="btn btn-default" value="Sign Up" style="margin-left: 15px;"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>But my login form works.</p>
  
  <pre><code>                    &lt;form action="&lt;?php echo plugins_url( 'login_submit.php', __FILE__ ); ?&gt;" method="post" autocomplete="off"&gt;
  
                        &lt;div class="list-block"&gt;
                          &lt;ul&gt;
                                  &lt;span class="ti-user"&gt;&lt;/span&gt;
                                  &lt;div class="item-input"&gt;
                                      &lt;input type="text" name="email"  placeholder="E-Mail"&gt;
                                  &lt;/div&gt;
                              &lt;div class="item-content margin-top-15"&gt;
                                  &lt;span class="ti-lock"&gt;&lt;/span&gt;
                                  &lt;div class="item-input"&gt;
                                      &lt;input type="password" name="password"  placeholder="Password"&gt;
                                  &lt;/div&gt;
                          &lt;/ul&gt;
                        &lt;/div&gt;
                        &lt;div class="log-in-btn margin-top-15 margin-bottom-30" &gt;
                          &lt;input type="submit" name="submit" class="btn btn-default"&gt;
                        &lt;/div&gt;
                        &lt;/form&gt;
  </code></pre>
  
  <p>I am confused as to what the difference is that would cause this.</p>