Send the form action either to your homepage, or to a specific page URL. You can’t have $_POST handling within the template because you need to redirect after your process it, and redirect needs to be fired before any HTML output.
// you should choose the appropriate tag here
// template_redirect is fired just before any html output
// see - http://codex.wordpress.org/Plugin_API/Action_Reference
add_action('template_redirect', 'check_for_event_submissions');
function check_for_event_submissions(){
if(isset($_POST['event'])) // && (get_query_var('pagename') === 'events)
{
// process your data here, you'll use wp_insert_post() I assume
wp_redirect($_POST['redirect_url']); // add a hidden input with get_permalink()
die();
}
}
You could also check for a nonce to make sure the data was submitted from the right place…
Related Posts:
- Applying OO patterns and principles to plugin development
- Is there documentation reference for forms in menu and setting pages?
- How to create a custom post-new.php page for plugin , no wp menu
- How to Maintain url on form submit
- Objective Best Practices for Plugin Development? [closed]
- How do i best handle custom plugin page actions?
- How to create an API for my plugin?
- Plugins in symlinked directories?
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- Best way to abort plugin in case of insufficient PHP version?
- What do you think about custom designed plugin/theme options UIs?
- Using a plugin class inside a template
- Where to put third party PHP library?
- Handling results from data hooked into admin_post
- What is the correct way to build a widget using OOP
- Optimize shortcode callbacks
- How to integrate a PHP webmail script into the backend of WordPress?
- How to make method from plugin available in theme?
- Is There A Hook To Process The Content Of The Text Widget?
- What is the recommended way to create plugin administration forms?
- Single Responsibility Principle and WP Classes
- How to log plugin errors to plugin error_log file
- Which to use to execute code during the saving of a plugin settings page?
- The ideal place for storing persistent PHP objects
- Custom theme sufficient or custom plugin neccessary for this feature set?
- When to check if a function exists
- How to create custom home page via plugin?
- Check spam in custom form – akismet
- Adding callback function for wp_ajax_ has no effect
- Sessions not creating correctly in custom function
- Use a PHP file as action for a form in a WordPress plugin, what’s the correct way?
- Featured Image not showing in admin
- Nuance in adding CPT and TAX to a submenu
- Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
- Plugin options page – form with two different submit buttons
- WordPress Ajax callback function from plugin – OOP
- How do you render_callback for register_block_type to a method in another class?
- Get the password key when using the wp_new_user_notification_email filter
- How to sanitize user input?
- How to deal with equal & similar arguments for a function?
- Disable The Events Calendar plugin from loading its scripts
- Advice on plugin structure
- Is it possible to change a term slug before being saved to the database?
- Maximum lifetime for nonce
- Custom Taxonomy to dropdown box on adminside wordpress
- Create a free scripts and styles template within a plugin
- How to modify the comments to be displayed in a post?
- How can I turn a custom wordpress page into a product page?
- Plugin Architecture Question: How to avoid using transients
- Incorporate small angular feature in my wordpress site
- How to Bind one post object Type with other postobject Type in Advanced Custom field [closed]
- Dynamically creating classes for Widget API
- WordPress class, using add_action to call member function does not work
- How should I go about registering JavaScript that isn’t a file? [duplicate]
- Show message from backend
- Why in this archive page that call query_posts() function show only the last 10 posts?
- WordPress plugin development OOP style
- The Correct Way to Use Nonce Field without Settings API
- How to add search form in main page body?
- How to make and save custom form in custom plugin page?
- Catching Form Submission in WordPress Admin Panel
- Converting core modification to a plugin
- OOP plugin not working
- Submit form to a different PHP file in the same plugin folder
- How to replace settings in WordPress plugin from a theme
- How to remove/replace current page template?
- How to determine which capability to use?
- Serial Number from custom table not appear in woocommerce_email_before_order_table action
- WordPress: redirecting to the form page after form submission to admin-post.php
- How to call a function from a shortcode function in an oop plugin
- Want to know how to reveal a WordPress theme, considering the theme name is hidden?
- Save meta box data from selected dropdown list in bbpress reply form
- Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?
- Performing ajax request in wordpress
- Use admin-post to submit form data to external database
- Create Customization panel for Plugins not for theme
- external Integration with wordpress timeout error
- How is construct function working even when variable is assigned null value?
- How to retrieve custom profile fields associated with different users
- Making adding info to an overlay bio easy for average user?
- form does not generate $_POST request
- Implementing Select2 plugin into WordPress
- Object Oriented plugin, add action and variables
- Can I use a hook other than ‘init’ to handle form submissions?
- Managing Custom Designed Content
- Can I access WordPress API’s from within plugin scripts?
- wp_mail links are dead
- Link to a admin submenu item using a custom link
- Change the search results header from plugin
- Tracing dashboard publish settings from input form in WordPress
- Post data in wp-admin to external database
- Client Profiles
- Multi-part form and wp_redirect()
- How do I create Widget within plugin that uses its own class?
- Submitting a plugin form to database in admin page
- Developing Themes on WordPress, Looking for Excellent Tutorials [closed]
- How to Implement SAM Broadcaster with WordPress? [closed]
- Extend WP_List_Table class – Edit wp_usermeta – WPPB.me Boilerplate – Action error
- Can I log the searches that are returning 404 in the DB?
- Developing an IP lookup function using an API