you can use admin-post.php
to process the form.
you can set the form like that :
<form
action="<?= htmlspecialchars(admin_url("admin-post.php?action=MY_PLUGIN__my_action"))?>"
method="POST"
>
<button name="send">go</button>
</form>
and then you link the code with that :
add_action("admin_init", function () {
if ( !isset($_GET["action"])
|| ("MY_PLUGIN__my_action" !== $_GET["action"])
) {
return;
}
/* */
// debug
var_export($_POST);
exit();
/* */
// data processing
//...
// redirection at the end
wp_redirection(home_url("done"));
exit();
});
Related Posts:
- How to store data from multiple forms using ajax and php
- How do I change/modify the_post_thumbnail(); html output?
- start_lvl Ignored in Custom walker_nav_menu
- Modify previous and next text from pagination links
- add_filter the_content str_replace after shortcode
- Inserting Gravity Form checkbox values into Advanced Custom Fields [closed]
- Calling a method from functions.php on a click of a button
- Creating wordpress user registration form
- HTML table from shortcode with multiple parameters
- Placing raw HTML inside a WordPress shortcode
- Slide in Panel WordPress Post
- Shortcode content output but not in correct place
- Upload Image in a WordPress page using PHP
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Using Multiple Submit buttons to trigger customised php functions
- Removing unneccessary p-tags (Not every p)
- Add a class to the anchor tag on HTML5 gallery
- My form action url is being prepended with a directory that does not exists
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Converting HTML Template to WordPress Theme
- Populate dropdown with Child Pages based on Parent Page chosen
- Use DOMDocument with ob_start breaks my HTML code
- Why Won’t My Inputs in a form with a Get method work together?
- Input data from email form not going to JSON file
- How to get the value of input hidden html from text editor to custom page template?
- Add .htm extention to a custom taxonomy
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Noscript not working as it should in wordpress site
- How to make modifications only to certain elements of an HTML string on the server-side?
- Search WordPress using static html page
- Widget back end radio button issue
- How to execute html code inside php?
- Shortcode to embed Edit Account form not working
- How to add post meta in while loop?
- Adding function to child theme’s function.php
- How to use the checked() function to check for a non-empty var
- Calling function in loop causes repeat data
- How can I use custom menus with a Bootstrap WordPress theme?
- Adding attribute to the post.php form tag in wp-admin
- WordPressUser Submission Form
- Custom forms with HTML
- Time Delay a URL Redirect for Specific Page
- how to changes mobile menu toggle breakpoint in WordPress
- Cascading dropdown select search based on Parent Page & Child Page
- WordPress User Meta value variable into Google Gauge Chart
- HTML Form Question
- Adding HTML Code to Replace Text in PHP
- Trying to update Woocommerce meta values
- PHP function for horizontal Woocommerce thumbnails and badges
- How to use data URL in WordPress?
- HTML comment cause issue in functions.php script root
- PHP multiple forms, same page, isset($_POST[]) not working?
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Remove span tags from WooCommerce Downloads page
- How to center all text body in single.php at once?
- How can I get my pagination loop to display the correct number of total pages?
- Creating wordpress user registration form
- wordpress form action page not found
- Can’t get_users info by using json_encode
- Show post/page into div using function
- Custom HTML form using PHP – help with ajax/username validation
- How to set up an auto delete post?
- Styling admin page rows in order of importance (checkboxes)
- WordPress HTML Helper
- Display default WordPress login/registration form into a modal window
- Cant get theme to change footer color through theme customizer
- Trouble using wordpress functions in a pop-up modal form
- ajax form function error
- Send foreach $_post method to contact form 7 [closed]
- Sorting Problem
- Contact form with dynamic dropdown and filter
- Add multiple HTML attributes to an Elementor button
- Display endpoint’s return into a file (file_put_contents())
- How can we upload custom page files?
- Custom PHP contact form issue
- Trouble getting wpdb to work – first time
- How to pass hook variable to function?
- Remove submenu item from list
- Get the alt text of the image in a array
- How to prevent a function from running based on host (ie web vs local)?
- call a string/function from database
- How to call custom function outside from the admin page?
- making php value numeric
- Replacing WordPress Icons (menu,icons32, etc)?
- Strip from or something better?
- Add a select-option to the default widgets
- Defining multiple categories for showing latest posts
- Display multi-select box choices in a bullet list [closed]
- the_post_thumbnail issues
- Is there a way to create a “copy post” link?
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Display additional page templates and a sidebar on plugin activation
- Dynamic Menu drops pages?
- Adding a ‘style=’ bit to image_send_to_editor output
- Shortcode displaying at the top of the page [duplicate]
- Post Views Code Hacks
- Closing WP_LINK_PAGES DIV ID w/After Argmuent
- Aspx/Rss feed – failed to open stream: Redirection limit reached
- Adding an Unlinked Space in a Custom Function
- exclude custom post type from running a function