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
- 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
- WordPress Update Plugin Hook/Action? Since 3.9
- Best way to abort plugin in case of insufficient PHP version?
- What are the advantages to the Settings API?
- What do you think about custom designed plugin/theme options UIs?
- Where to put third party PHP library?
- Optimize shortcode callbacks
- How to integrate a PHP webmail script into the backend of WordPress?
- add_action with a class method is causing fatal errors
- How to log plugin errors to plugin error_log file
- Do I need to call do_action in my plugin?
- How Do I Load My Action Earlier Enough?
- Allowing for multiple template views on the Gallery Settings page when using the Visual Editor
- 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 to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- How to create custom home page via plugin?
- Is it possible to create an action hook using do_action() within add_action()?
- Sessions not creating correctly in custom function
- When is it too late to call the action wp_enqueue_scripts?
- Featured Image not showing in admin
- What is the Difference between directly call a function and call a function using add_action?
- Extend plugin options page
- Woocommerce – Hide a Column in Cart Table
- Get the password key when using the wp_new_user_notification_email filter
- Order properties should not be accessed directly
- How to add settings subpage from a plugin to a settings page created in theme?
- How to deal with equal & similar arguments for a function?
- Which are the hooks run before/after when a category’s deletion?
- Customizer: widget-synced triggers twice
- null callback in add_settings_section
- how to use hook deleted_user into custom function to delete user from custom table
- Namespaced action and filter tags
- Disable The Events Calendar plugin from loading its scripts
- Where to store the name of a custom table?
- WordPress is automatically linking plain text email addresses
- Is Using WordPress Supplied WYSIWYG Advisable?
- Single sanitization callback for multiple fields
- Callback is not called in add_settings_field() when passed as part of an array, but recognises that it’s there. It’s passed Class to Class using OOP
- When to use add_settings_section vs just register_setting?
- How to fix Uninitialized string offset: error on a checkbox in WP Settings API
- Custom Taxonomy to dropdown box on adminside wordpress
- How to modify the comments to be displayed in a post?
- Plugin with action ‘save_post’ needs to press publish twice on order to publish
- wp_set_object_terms not updating database without a die()
- Settings API with arrays example
- Allow users to add / remove settings in plugin
- Update problem with update_option() in combination with register_setting()
- load_plugin_textdomain doestn’t work with add_action plugins_loaded
- Show error message after exception handled
- How to modify files inside wp-includes directory in wordpress
- Bug: Post needs to be updated twice when adding action for save_post hook
- Delete data from database using row action
- When does save_post hook fire on post save/update
- Default settings aren’t used
- Show message from backend
- Issue on Checkbox with Custom Option Page
- Create Widget or Enable Shortcodes in Sidebar
- Call to undefined function is_home() or any conditional tags
- how to save wp_editor html content in options table
- settings api – add_settings_section not working
- Include HTML (Bootstrap Modal Box) with a plugin into my header
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- How to remove/replace current page template?
- Adding tables to dashboard pages programmatically?
- How to determine which capability to use?
- It is possible to pass $args that sent by add_settings_field() inside another function?
- Why won’t this submenu page show? – My First WordPress Plugin
- Where do I hook to have the server do something in PHP on block attribute change?
- Post is uncatagorized in publish_post action
- Hide / show settings field based on other field’s value
- remove different admin menu for specific users
- WordPress Reset password Strength set to medium
- Determine if the current page, is being edited
- external Integration with wordpress timeout error
- add_settings_error on validating plugin options API
- Making adding info to an overlay bio easy for average user?
- Implementing Select2 plugin into WordPress
- Associating special meaning with user id 0
- Can I access WordPress API’s from within plugin scripts?
- When using an options array the Settings API isn’t creating the database record
- Link to a admin submenu item using a custom link
- Change the search results header from plugin
- Dynamic banner for use on external sites
- How wordpress plugin hooks works? [duplicate]
- Developing Themes on WordPress, Looking for Excellent Tutorials [closed]
- How to Implement SAM Broadcaster with WordPress? [closed]
- WordPress Plugin default option
- Apply function on all action hooks?
- Extend WP_List_Table class – Edit wp_usermeta – WPPB.me Boilerplate – Action error
- How to use register_setting()
- Ninja Forms: Front-End Forms, Post ID?