tags:

views:

12

answers:

1

i am picking up wordpress development and reading the book digging into wordpress. i have the code below in functions.php

<?php
add_action('admin_menu', 'addAmazonAffiliateOptions');

function addAmazonAffiliateOptions() {
  add_options_page('Global Custom Fields', 'Global Custom Fields', 8, 'functions', 'editGlobalCustomFields');
}

function editGlobalCustomFields() { ?>
  <div class="wrap">
    <h2>Global Custom Fields</h2>
    <form action="options.php" method="post">
      <?php wp_nonce_field('update_options'); ?>
      <p>
        <label for="amazonId"><strong>Amazon ID</strong></label>
        <input type="text" name="amazonId" value="<?php echo get_option('amazonId'); ?>" />
      </p>
      <p>
        <input type="submit" name="submit" value="Update Options" />
        <input type="hidden" name="action" value="update" />
        <input type="hidden" name="page_options" value="amazonId" />
      </p>
    </form>
  </div>
<?php }

when i try to save the options, i get

Your attempt to edit your settings has failed.

how do i debug such things in wordpress?

A: 

I think you need to be using register_setting() - the WordPress core and API has changed quite considerably since that book was published.

Check out the codex on WordPress 2.7+ for adding plugin options pages.

TheDeadMedic