Is there a hook attached to general settings save?

I want to add a field to the general settings page, but I can not save the field because I can’t find a hook for the pages save.

Any ideas?

Related posts

Leave a Reply

1 comment

  1. You just need to register_setting() on your setting and it will be saved automatically. See the Settings API for more info. Here’s a complete example:

    function spw_cb() {
        if( !($value = get_option('sprockets_per_widget')) ) {
            $value = 7;
        }
    
        ?>
        <input type="text" size="3" name="sprockets_per_widget" value="<?php echo $value; ?>" /> Numeric only!
        <?php
    }
    
    function spw_init() {
        add_settings_field('sprockets_per_widget', 'Sprockets per Widget', 'spw_cb', 'general');
        register_setting('general', 'sprockets_per_widget', 'intval');
    }
    add_action('admin_init', 'spw_init');