I’m building a plugin and would like to add a dashboard widget with a custom form. In this form, users should be able to edit a list of strings (add, edit and remove items). Is there a WordPress API to do something like that? I already know how to add a dashboard widget, but I don’t know how to make a form in a dashboard widget / how to process the data.
The only thing I can think of is to redirect the user to my options page – there must be a neater way. Is there any?
There are two options to use forms in a dashboard widget:
Use the parameter
control_callback
. See the CodexIf you want to use a form in the main display handler, set the form action to
admin-post.php
and add a callback function for a customaction
there. Example. When you are done processing the form redirect back to the dashboard.