If you’re using Settings API, then you should use a sanitize callback:
register_setting( $option_group, $option_name, $sanitize_callback );
The myth is that the $sanitize_callback
actually is a filter for your options when it’s saved in the database. This is the place where you can do something with your custom code.
This is the sample code:
register_setting( 'wpse38180', 'wpse38180', 'sanitize_wpse38180' );
function sanitize_wpse38180( $options )
{
// Do anything you want
return $options;
}
Related Posts:
- How to create an API for my plugin?
- add_option_{$option} action hook not being called
- Objective Best Practices for Plugin Development? [closed]
- Difference Between Filter and Action Hooks?
- Settings API with arrays example
- How do i best handle custom plugin page actions?
- Is it ever okay to include inline CSS in plugins?
- Plugins in symlinked directories?
- How to override existing plugin action with new action
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Which hook should be used to add an action containing a redirect?
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- Plugin Form Submission Best Practice
- Is get_option function cached?
- WordPress Update Plugin Hook/Action? Since 3.9
- Best way to abort plugin in case of insufficient PHP version?
- How can I configure Docker for developing and deploying a custom theme?
- What are the advantages to the Settings API?
- What do you think about custom designed plugin/theme options UIs?
- No Error Log File, no debug info
- Where to store plugin settings fields
- How to Use Checkbox in Custom Option Page Using The Setting API
- How should one implement add_settings_error on custom menu pages?
- Where to put third party PHP library?
- Is the new WordPress 3.1 admin bar pluggable and how can I extend it?
- How to use PanelColorSettings in custom Gutenberg block?
- Getting a peer review for my new plugin?
- Optimize shortcode callbacks
- Accessing plugin settings in gutenberg
- What’s the best method for emptying an option created with the Settings API?
- Which action for triggering cron “wp”or “init”?
- How to integrate a PHP webmail script into the backend of WordPress?
- Using filters and actions for plugin API?
- Is There A Hook To Process The Content Of The Text Widget?
- add_action with a class method is causing fatal errors
- How to Change the Entire WordPress Admin panel Look and Feel?
- How to log plugin errors to plugin error_log file
- How do you use the plugin boilerplate loader class to hook actions and filters?
- add_filter OO with parameters
- How do I print a notice only on certain admin pages?
- Do I need to call do_action in my plugin?
- How Do I Load My Action Earlier Enough?
- Does WP fire delete_post when trashed posts are automatically deleted?
- Allowing for multiple template views on the Gallery Settings page when using the Visual Editor
- Nonce in settings API with tabbed navigation
- What’s the earliest point I can get the queried object ID?
- How do I Make a Theme “plugin-ready”?
- Using Primary Color in Plugin Block
- A Post is saved twice or more during add_action(save_post)
- When is it appropriate to put functions on page template vs. functions.php?
- How to use the settings API to set multidimensional arrays
- How can I limit functionality in one version of a plugin?
- Actions or filters fired when data is saved in a custom table
- In a plugin, why is add_action(‘init’) not executed before the plugin is activated?
- Custom theme sufficient or custom plugin neccessary for this feature set?
- When to check if a function exists
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- How to create custom home page via plugin?
- Add Admin Menu Inside Construct or Init
- What action is called when drafts are saved?
- Adding callback function for wp_ajax_ has no effect
- Why won’t register_setting() create a setting?
- Is it possible to create an action hook using do_action() within add_action()?
- Sessions not creating correctly in custom function
- Settings API – Undefined Index when unchecking checkbox
- How can I hook into existing WordPress Bulk actions?
- When is it too late to call the action wp_enqueue_scripts?
- Disable $title in Plugin Options Screen?
- Featured Image not showing in admin
- Odd behaviour with submenu link creation
- WordPress Settings API: saving multiple rows of similar data
- How to use wp_set_password in a plugin?
- Why isn’t the Settings API designed to work for plugins using custom admin menus? [duplicate]
- What is the Difference between directly call a function and call a function using add_action?
- How to add custom content under plugin row in WordPress admin plugin list?
- How Can I setup WP CLI on Windows development machine running AMPPS?
- Can a plugin add to header/footer/body content?
- WP_LOCALIZE_SCRIPT doesn’t work
- Define a function outside a class and call the function using action or filter hook
- Create a plugin to change the action to which a function is hooked
- Does settings API create settings on run time?
- Nuance in adding CPT and TAX to a submenu
- Performance of several get_option() calls
- What is the use of get_option method
- Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
- Extend plugin options page
- Can I use the different settings sections over different pages using the save options group?
- Delete a specific item menu when I deactivate my plugin
- Modifying values with add_action to be sent to db
- Woocommerce – Hide a Column in Cart Table
- Are we allowed to use the Allman (BSD) indent style when coding WordPress plugins and themes?
- Generating User(s) with Settings API
- How to redirect to action on custom page within admin section
- Callback function is being called twice
- plugin development: storing language specific options
- How to add a secondary button to a settings page with a custom action?
- Correct way check nonce (security) using old Options API
- Tabbed navigation for plugin options using same row in database for all?
- admin_notices not displaying in plugin