I've created a form for my plugin settings and set the action attribute of the form to "options.php" but when I submit the form I get "ERROR: options page not found."

add_action('admin_menu', 'create_menu');

function create_menu(){
    // add menu page
        'Basic Plugin Menu Page', 
        'Bp Menu', 
        plugins_url('images/wordpress.png', __FILE__),
        76 );
    // add submenu page
        'Besic Plugin Submenu', 
        'bp_options_cb' );
    add_action('admin_init', 'bp_register_settings_cb');
} // end add_menu
function bp_register_settings_cb(){
    // - register_setting( $option_group, $option_name, $sanitize_callback );
    register_setting('bp-settings-group', 'bp_options', 'bp_options_sanitize');
} // enb bp_register_settings_cb

function bp_options_sanitize($input){
    $input['name'] = sanitize_text_field($input['name']);
    $input['email'] = sanitize_email($input['email']);
    $input['url'] = esc_url($input['url']);
    return $input;
} // end bp_options_sanitize

function bp_menu_cb(){ ?>
    <div id="wrap">
        <h2>Basic Plugin Settings</h2>
        <form method="POST" action="http://localhost/blogger.allaudin/wp-admin/options.php">
            <?php settings_fields('bp_settings_group'); ?>
            <?php $bp_options = get_option('bp_options') ?>
            <table class="form-table">
                <tr valign="top">
                    <th scope="row">Name</th>
                        <input type="text" name="bp_options[name]" value="<?php echo esc_attr($bp_options['name']) ?>" />
                <tr valign="top">
                    <th scope="row">Email</th>
                        <input type="text" name="bp_options[email]" value="<?php echo esc_attr($bp_options['email']); ?>" />

                <tr valign="top">
                    <th scope="row">URL</th>
                        <input type="text" name="bp_options[url]" value="<?php echo esc_url($bp_options['url']) ?>" />
            <p class="submit">
                <input type="submit" class="button-primary" value="Save Changes" />
<?php } // end bp_settings_page
  • In the function bp_menu_cb(), you have used settings_fields('bp_settings_group'); but it should be settings_fields('bp-settings-group'); because in the function bp_register_settings_cb() you have used "bp-settings-group" and not "bp_settings_group"
    – Domain
    Sep 21, 2015 at 7:57

1 Answer 1



bp_settings_group should be changed to bp-settings-group to match.

settings_fields( $option_group )

$option_group should match the group name used in register_setting() i.e bp-settings-group.

check on codex here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.