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
- How to fix ‘Notice: Undefined index:’ in PHP form action
- Return HTML Template Page with PHP Function
- Genesis – Customize search form
- Fatal error: Call to undefined function plugin_dir_path()
- How to use copy() function and paste file in /wp-content/themes directory
- wordpress custom endpoint multiple params
- How to return multiples lines in a shortcode?
- How do I turn a shortcode into PHP code?
- How to return a foreach inside a shortcode
- Page Reloads Before AJAX Request Finishes
- Add htaccess rules with insert_with_markers at beginning of htaccess
- Shortcode content output but not in correct place
- Insert array data on plugin activation
- PHP code inside shortcodes
- Adding Default Settings to Theme My Login plugin
- Hide categories that are not used in the post type
- WordPress ajax doesn’t display object method on jQuery .change() function
- filter default query to show just selected level of child pages in wordpress
- How to make my custom widget appear within WordPress widgets? Plugin development
- Pass php dynamic variable to shortcode
- Input data from email form not going to JSON file
- do_shortcode with custom field
- Remove echo from shortcode
- Font Awesome changing default WordPress Font
- Download full html page with CSV export plugin
- $wpdb returns duplicate posts
- Shortcode to find and replace URL
- Usage of call back function of add_meta_box()
- how to save checkbox data for custom setting?
- Can a plugin redirect product page based on IF condition?
- Save html content of a widget textarea
- Why does my settings form redirect to the homepage?
- Shortcodes showing in excerpt despite using strip_shortcodes
- How to override a plugins script
- Adding attribute to the post.php form tag in wp-admin
- Front end file upload returning wrong attachment url
- MySQL Query Returns Array () In Shortcode
- Plugin won’t output characters with diacritics properly
- Why is my shortcode not working?
- WP Hook Before a post is created
- ACF relationship on user profile page used for allowed access
- Echo short code syntax
- Changing Date Format on Custom Meta Data w/shortcode call
- Need help with format of nested array in MySQL
- Updating the database after parsing CSV document
- Offset with ajax load more posts duplicates
- How to add delete, approve, spam Links to Comments
- How can i iterate through this shortcode array?
- Setting at job with shortcode not working
- Run code before WordPress loads and insert data into WP if need be
- Shortcode in a $output statement
- Need help with PHP functions
- PHP: Why does my code work in index.php but not a widget?
- Run PHP Results inside WP Shortcode
- Styling admin page rows in order of importance (checkboxes)
- On selecting shortcode generate selected shortcode table inside page editor worrdpress
- Accessing Variables Used In a Plugin Using PHPStorm + XDebug
- Data inserted in database, but ajax calls error function
- upload images on front by user using form
- My title is showing after the shortcode
- Shortcode to include PHP file, pass various parameters to include?
- I’m not able to get access $wpdb in my php file in wordpress
- Implement OAuth2 in custom plugin
- login redirect based on user role not work as expected
- redirect user from login page if is logged
- How to lock users account until approvation
- Variable ++ in query loop