WordPress has a generic handler to deal with all forms – admin-post.php.
If you include a hidden field in your form called action, you can then hook in to a function of your choice with all the goodness of wordpress included.
echo "<form action='".get_admin_url()."admin-post.php' method='post'>";
echo "<input type="hidden" name="action" value="submit-form" />";
echo "<input type="hidden" name="hide" value="$ques" />";
{ Enter the rest of your first block of code from above here }
And then in your functions.php file (or any other php file that you have included via functions.php), you can use this method.
add_action('admin_post_submit-form', '_handle_form_action'); // If the user is logged in
add_action('admin_post_nopriv_submit-form', '_handle_form_action'); // If the user in not logged in
function _handle_form_action(){
{ Enter your second block of code from above here }
}
Related Posts:
- Simple form that saves to database
- Get selected values from checkboxes and radio buttons via Gravity Forms gform_after_submission hook [closed]
- shortcode doesn’t work
- Template plugin for blog posts? [closed]
- Trying to add admin file upload form plugin
- How to disable autocomplete for inputs in contact form 7? [closed]
- WordPress Custom Application form
- When is it useful to use wp_verify_nonce
- Datepicker not supporting timepicker
- add function to saving change on Options Pages
- Admin page: form with enctype=”multipart/form-data” does not transfer its data
- Retrieving a Value from a wp-database
- Hook into and send mail using WP Mail SMTP type plugin from HTML static front page?
- Custom form action to handle data inside a plugin
- wp_create_nonce function doesn’t work inside a plugin?
- Form isn’t inserting data into database with ajax plugin
- New User Form – Custom Menu Page
- Anonymous Postings
- Contributive page where people logged in can write
- Contact Form 7 Get Image Function [closed]
- Submit page limited in time to upload image
- Is there any way to use google input tool or any other language keyboard with WordPress [closed]
- Ajax fail and get 504 error
- Take input from form and pass it to function using a wp-plugin
- Checkbox conflict in my custom plugin admin page
- Trying to fix form resubmition with PRG (Getting error: Cannot modify header information – headers already sent by)
- WP Plugins – Use includes to display page content
- Plugin to create forms using HTML [closed]
- How to allow user to select User ID in Formidable Pro form? [closed]
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Detailed form plugin, with ability to export to excel etc. OR edit PDF live? [closed]
- How do I add the same contact form to multiple wordpress sites and capture the response in one place or database?
- wp_enqueue_style on template_redirect level?
- How can ι create my own (custom) WordPress table/list?
- Gravity Forms returns to odd position
- WordPress Multi-Step Product Search
- Sell access to form [closed]
- File Uploader – Upload without adding to Media Library
- Custom form not showing in correct place on page
- How to redirect to a page after the form is submitted
- How to Use the Filter “sidebar_login_widget_form_args”
- Select Form Element Not Saving from Plugin Options
- Is it save to replace with in WordPress search form
- Contact Form 7 Plugin emails not being received by some accounts
- Plugin for visitors to edit content without logging in? [closed]
- How do I send the contents of a form to deliver to the already existing custom field in the wordpress theme
- Linking form to user meta fields
- WordPress Forms Advance Conditional Logic
- User loggedin as Subscriber form not sending
- login form should redirect to register page for in 1st login next time it should redirected to home page
- How to get data from a form on a wordpress site?
- Submitting form to PHP
- General Term for this form Field
- wp_set_password() does not work!
- Custom Formdata matching with user table
- Hide button after form submit and save state to localstorage
- Why is my form going to frontend on html form submission present on the php files inside my custom plugin?
- Meta Key array building with multiple input values from fields
- Creating posts with acf_form() that has a relationship type field
- Plugin to manage form submissions on admin panel
- How to send custom mail when a user complete a specific form
- How to submit custom form data using ajax to HubSpot form?
- Ajax call to php function doesn’t work PHP code
- submit form data to wordpress existing database table using my plugin
- After form submission want to show success message in the form page
- Pause form submissions while upgrading plugins
- How to hide the form after successful php execution
- How can I automatically send an email with an excel file containing submissions for a form rather than an email per submission?
- Why doesn’t a form need an ‘action’ with a plugin that uses the post data?
- $POST variable is empty in receiving php add-on function but can be seen by jscript function
- WP_Filesystem usage within a block of code
- I created a custom form in HTML/CSS and now I need it to submit … should I create custom PHP or is there a plugin I can use?
- Include plugin form in the home page
- How can i see/log all requests coming from a registration form (not from the UI)?
- Form submit from wordpress plugin
- How do I convince this button to do something when it is clicked?
- wordpress option page data from select form is not saving to database
- Linking Plugin Files to WP
- Carrying information from button click into form [closed]
- Custom Form only for admin
- County Finder form/plugin?
- Creating fields in the database
- Allow users to enter and edit data in one-to-many configuration
- Plugin Admin Page Ajax-Admin call returning 0, URL set correctly. Implemented localized scripts but did not fix it
- Can’t edit Contact Us form on front page
- Build a Boat Form Plugin [closed]
- How to get an error message if a form is empty (plugin: Post for site) [closed]
- Redirecting to page on form submit – Revue plugin
- How to Allow Users to Select Recipients In a WordPress Comment section?
- WP Donation Form with custom payment API
- Form with response button after on table after submission
- Tips on using a custom template with Ultimate Member
- Can’t save formdata in DB
- Display file contents within Plugin
- Gravityforms login form custom redirect if form not submitted
- i need to resive data external api and show user
- Trying to Find the PHP File/Function that Handles a Specific Form Action URL
- Issue using form in Google app in mobile
- add to cart linking to add to cart page
- Missing Contact Form/Form Default Plugin in WordPress