Change form.php
<form action="<?= $_SERVER["REQUEST_URI"]; ?>" method="post">
<input type="hidden" name="form_submit_nonce" value="<?php echo wp_create_nonce('form-submit-nonce'); ?>"/>
<label for="id">ID</label>
<input id="id" name="id" type="text" value="" required />
<input type="submit" name="submitid" value="Submit">
</form>
Change plugin file
function form_shortcode(){
if ( isset( $_POST["submitid"] ) && isset($_POST['form_submit_nonce']) && wp_verify_nonce($_POST['form_submit_nonce'], 'form-submit-nonce') ) {
echo "<p>OK</p>";
} else {
include "form.php";
}
}
add_shortcode( "form", "form_shortcode" );
Related Posts:
- Retrieve multiple values passed to a single attribute in a shortcode
- Display a text message if the shortcode is not found?
- shortcode doesn’t work
- Loading page template into shortcode
- My shortcode is showing up twice
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- Making Quote Plugin more efficient
- custom shortcode will not display the wrapped content
- Append HTML Using Shortcode
- Plugin CSS not enqueing
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- How to put a form with php code into a variable or shortcode?
- Shortcode to embed Edit Account form not working
- Using admin-post.php for admin form but it directs me to admin-post.php white screen
- Action Hook Inside WordPress Plugin Shortcode
- Adding Additional Variables on Menus Page
- What is the difference between Null vs Empty (Zero Length) string?
- How to Create custom block for displaying information in content section which act like shortcode
- PHP multiple forms, same page, isset($_POST[]) not working?
- Display a custom name when the user has no name settle in his account
- Store user form submitted information in post type
- overwrite wordpress gallery with custom gallery shortcode
- How to return html as a string from php for WordPress
- not able to access $_POST on backend profile update
- Custom Plugin Develoment, Form Action
- Shortcode Works for Logged in Users but Not Working for Guest
- Using Nonce for my Form
- Trouble using wordpress functions in a pop-up modal form
- using a shortcode in a hyperlink
- WP Custom tables query
- Redirect loop upon installation of my plugin
- Custom plugin with shortcode not working
- Automatically populating a date parameter within a shortcode
- Change Password Hint
- Has anyone tried putting PHP ActiveRecord on WordPress?
- Handling error states with admin_post
- submit the form to same page
- has_shortcode() – how to detect nested shortcode
- Theme url in all plugin pages
- Placing raw HTML inside a WordPress shortcode
- what is the best practice to add new field to an api route
- Use custom post type for a store locator
- How can I hide that I Use WordPress (with W3 Total Cache)
- Embedding PHP in shortcode $content
- Shortcode with PHP issue “Undefined index”
- User register hook is not working in woocomerce register form
- Custom array from a query only write the last row of the query
- Is There A Way To Make Theme Files Accept Shortcodes?
- Create a WordPress shortcode using PHP [duplicate]
- How to send form data from WordPress (Meta Box) to an OData service?
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- calling a custom field value inside functions.php
- Using ob_start and ob_get_clean with wordpress shortcode
- Custom meta box values are not getting saved for my custom post type
- Plugin development and composer
- Set default Database Storage Engine when creating tables with plugins?
- custom post type with role Vendor
- Pass important values server-side when processing form
- Execute Jquery when a specific page in my plugin is loading
- AJAX function not working [closed]
- Can ‘Custom Field’ data be inserted into this Short Code?
- WordPress can’t use ZipArchive
- How do I reopen the (Popup Maker) after entering the correct password for a password protected page?
- Not able to remove caption shortcode from the content
- Only the first image uploads
- WordPress loading progess – wp-blog-header.php
- Custom plugin: how do I call a PHP file if settings option is set to true?
- I want it to detect the duplicate comment and give a warning on the same page
- Trying to use a variable to set image width
- Shortcodes not processing inside post content
- Gravity Forms: How to add PHP function to confirmation conditional shortcode?
- wpdb->query returns different value to phpMyAdmin
- wp_update_post gives 500 internal error
- How to identify which php file a plugin is using on page load?
- dashboard widget form not submit mails
- I want to hide “sold by” on certain pages with id page 43
- register_setting not save checkbox
- How to add a PHP scripts into WordPress
- How does one make a URL return dynamic JSON with custom Content Type?
- Shortcode just with a php code
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Custom post type single page return to listing page
- Contact form field in wordpress menu
- php string inside shortcode does not work
- Shortcodes (with a space) added to php Sample
- WordPress rewrite question
- Create new folder and upload files to custom folder via wp_handle_upload
- How to pass username into form that sends data to database
- Display Current Time using shortcode
- How to create shortcode of this PHP code
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- Too few arguments at registering new templates in my plugin
- I want to lists posts in wordpress to nearest location entered by the user
- How to edit a widget code?
- Translate string in another langage than Locale
- Integrate a Custom Post Type with Learndash Plugin
- Nav Menu Short code Not working When non Login
- Remove slug of multiple custom post types with and without hierarchical