I'm creating an options page in WordPress admin interface. How can I run a PHP function before a submit is made?
My HTML:
<div class="wrap">
<h2>Author</h2>
<form method="post" action="options.php">
<?php settings_fields('author_option_group'); ?>
<h4>Author Settings</h4>
<label for="author">Author: </label>
<input type="text" id="author" name="author" value="<?php echo get_option('author'); ?>" />
<?php submit_button(); ?>
</form>
The submit_button()
above is a wordpress function that generates a submit button that saves the input field to the wp options table in the database. I would like to run a function before the submit is run. The function will do some custom validation etc and maybe throw an error and not run the submit if certain conditions are met.
Regardless of what that function will do, how can I supply a function to be run, which determines if the submit will go through or not?