开发者

Wordpress adding custom field update fails

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" valu开发者_如何学Pythone="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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜