0

I am writing a WordPress plugin that has a dashboard URL like this...

http://www.mydomain.com/wp-admin/admin.php?page=my-plugin.php

I have a datepicker box within the page that I use to select a date then click submit like this...

<form action="http://www.mydomain.com/wp-admin/admin.php?page=my-plugin.php" method="get">
<input type="text" class="mydatepicker" name="start_date" value=""/>
<input type="submit" value="submit">
</form>

I am expecting the page to reload with a URL like this...

http://www.mydomain.com/wp-admin/admin.php?page=my-plugin.php?start_date=2014-04-03

But instead i get this...

http://www.mydomain.com/wp-admin/admin.php?start_date=2014-04-03

What am I doing wrong?

3

Try to use this code,

<form action="http://www.mydomain.com/wp-admin/admin.php" method="get">
<input type="hidden" name="page" value="my-plugin.php" />
<input type="text" class="mydatepicker" name="start_date" value=""/>
<input type="submit" value="submit">
</form>

This will show the url like this...

http://www.mydomain.com/wp-admin/admin.php?page=my-plugin.php&start_date=2014-04-03

Check and let me know your comments, if it works

  • Okay Great.. Please mark it as resolved. So others will get help from this – Harish Chinju Apr 21 '14 at 13:54
  • You save my day. This should be documented in the codex.... – ucheng Apr 25 '18 at 9:42
0

Your page reference is held in $_REQUEST['page'] so rather than hard coding your plugin page, use that.

  • Where is anything hard coded? Aside from that, this is more a comment as it doesn't explain what helps solving the problem. – kaiser Sep 25 '14 at 2:44
  • You're correct on the comment part, apologies; What I'm saying is don't use example.com/wp-admin/admin.php in action field use the value from $_REQUEST['page'] then your page will be poertable to any domain. – Fuzzy Jan 13 '15 at 13:56
  • Please file an edit and show a full example (probably best with included validation). You may want to take a look at the help center and see how to write a good answer as yours was auto flagged as low quality :) – kaiser Jan 13 '15 at 16:54

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.