WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For some reason I am unable to save the data from my form:

add_action( 'admin_menu', 'example_menu_settings' );

/** Step 1. */
function example_menu_settings() {
    add_options_page( 'example Plugin Options', 'example', 'manage_options', 'example-settings', 'example_plugin_options' );
    add_action( 'admin_init', 'register_example_settings' );

/** Step 3. */
function example_plugin_options() {
    if ( !current_user_can( 'manage_options' ) )  {
        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );

    $client_id = get_option('example_client_id', '');
    $secret = get_option('example_secret', '');

    echo '<div class="wrap">
      <h2>example Plugin Settings</h2>
        <form method="post" action="options.php">';
        settings_fields( 'example-settings-group' );
        do_settings_sections( 'example-settings-group' );
        echo '<input type="hidden" name="option_page" value="general"><input type="hidden" name="action" value="update"><input type="hidden" id="_wpnonce" name="_wpnonce" value="103f63adef"><input type="hidden" name="_wp_http_referer" value="/example-Blog/wp-admin/options-general.php">
          <table class="form-table">
            <tr valign="top">
            <th scope="row"><label for="example_client_id">Client ID</label></th>
            <td><input name="example_client_id" type="text" id="example_client_id" value="' . $client_id . '" class="regular-text">
            <tr valign="top">
            <th scope="row"><label for="example_secret">Secret</label></th>
            <td><input name="example_secret" type="text" id="example_secret" value="' . $secret . '" class="regular-text">
            <tr><td colspan="2" class="description" style="padding: 25px 0 10px 0;">Your keys is found inside your <a href="https://example.com/user" target="_blank">example account settings</a>.</td>
            <button id="example-test-connection" class="button">Test connection</button>';
            echo submit_button();
        echo '</form>

function register_example_settings() { // whitelist options
  register_setting( 'example-settings-group', 'example_client_id' );
  register_setting( 'example-settings-group', 'example_secret' );

Here is the error I get:

Are you sure you want to do this?

Please try again.

This is the /wp-admin/options.php page.

What am I doing wrong?

share|improve this question
up vote 2 down vote accepted

There is a hidden field named _wpnonce in your form including hard coded value, plus another field named _wp_http_referrer. You better remove these, and let settings_fields() generate them. (it should already do so).

share|improve this answer
Give codex.wordpress.org/WordPress_Nonces a look. Agreed with @jörn. – MikeNGarrett Jan 27 '14 at 2:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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