Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'template_redirect', 'wpse149613_form_process' );
- function wpse149613_form_process(){
- if(!isset($_POST['submit'])) // assuming you're using POST and submit button name is 'submit'
- return;
- // Validate the form, verify nonce
- // process form
- }
- <form action="<?=admin_url( 'admin-post.php' ) ?>" method="POST">
- <!-- your inputs -->
- <input type="hidden" name="action" value="myplugin_mycustomaction"/>
- <input type="submit" value="Send"/>
- </form>
- add_action( 'admin_post_nopriv_myplugin_mycustomaction',array( "class_that_owns_that_function", 'yourmethod' ) );
- public function yourmethod()
- {
- // Do what you want with $_POST variables
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement