So, I need to add a custom options page, and based on as many tutorials I could find, I came up with the following code to create an officers & chairs options page for my group, mainly, so I can write more advanced stuff for my site. The code is here:

add_action('admin_menu', 'composit_settings_page');

function composit_settings_page()
    add_options_page('Officers & Chairs', 'Officers & Chairs', 'manage_options', 'officers_chairs', 'composit_settings');

function composit_settings()
    $actives = get_users('role=contributor');
    $actives = array_merge($actives, get_users('role=editor'));
    $actives = array_merge($actives, get_users('role=administrator'));

$positions = array(

    <div class="wrap">
        <div id="icon-options-general" class="icon32"><br></div>
        <h2>Officers & Chairs</h2>

        <form method="post" action="options.php">
            <?php settings_fields('officers-chairs'); ?>
            <?php foreach($positions as $position):
                    register_setting('officers-chairs', $position, 'intval');
                  endforeach; ?>
            <table class="form-table">
                    <?php foreach($positions as $position): ?>
                        <tr valign="top">
                            <th scope="row">
                                <label for="<?= $position ?>"><?= ucwords($position) ?></label>
                                <select name="<?= $position ?>" id="<?= $position ?>" class="regular-text">
                                    <?php foreach($actives as $active): ?>
                                        <option value="<?= $active->ID ?>" <?php if(get_option($position) == $active->ID) { ?> selected <? } ?>><?=$active->first_name . " " . $active->last_name ?></option>
                                    <?php endforeach; ?>
                    <?php endforeach; ?>
            <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes"></p>

However, when I go to save that, I get the following error:

ERROR: options page not found.

I feel completely dumb for not being able to figure this out, but the official documentation hasn't really helped me at all.

1 Answer 1


The problem part is this line:

<form method="post" action="options.php">

This sends your form to wp-admin/options.php (and I guess you're not sending the form from this URL). Leave the action value empty like this:

<form method="post" action="">

And your form will send itself to the same page from which it was sent. Then you can save the settings accessing $_POST variable before outputing

<form method="post" action="options.php">...

Hope this helps...

PS: you should also consider using wordpress nonces. Eg. https://codex.wordpress.org/Function_Reference/wp_nonce_field

  • Save settings before output? Know the function off hand?And there is a wpnonce field in there once the page actually outputs. update_option(). We'll see if this works. Mar 6, 2013 at 16:37
  • Not sure I understand this answer. The options page is defined by a function. You have to run through validation before saving and the saving should be a separate function.
    – AlxVallejo
    Jun 6, 2013 at 17:54

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.