WordPress – Error: Options Page Not Found

I know there’s a few solutions out there for this problem, but none of them seem to fix my code.

I’ve been following a lynda.com tutorial on creating plugins. However I believe they are using an older version of wordpress, which is why I think I’m running into trouble.

Read More

I’m trying to add an options page, but everytime I “save” on my options page it gives me “not found” error for the options.php page.

  • Tried linking to options.php directly (with full URL), no dice.
  • Tried changing register_setting to both equal the same thing, as stated in WordPress Codex, but that didn’t work.

Here’s my code:

function cc_init(){
    register_setting('cc_options,','cc_cc_email');
}add_action('admin_init','cc_init');


function cc_option_page(){
    ?>
    <div class="wrap">
    <?php screen_icon(); ?>
    <h2>CC Comments Options</h2>
    <p>Welcome to the CC comments plugin. here you can edit the email(s) to CC your comments to.</p>
    <form action="options.php" method="post" id="cc-comments-email-options-form">
    <?php settings_fields('cc_options'); ?>
    <h3><label for="cc_cc_email">Eamil to send CC to:</label>
    <input type="text" id="cc_cc_email" name="cc_cc_email" 
            value="<?php echo esc_attr(get_option('cc_cc_email')); ?>" /></h3>
    <p><input type="submit" name="submit" value="Save Email" /></p>    
    </form>
    </div>
    <?php
}

function cc_plugin_menu(){
    add_options_page('CC Comments Settings','CC Comments','manage_options','cc-comments-plugin','cc_option_page');
}add_action('admin_menu','cc_plugin_menu');

Related posts

Leave a Reply

1 comment

  1. I think I had my add_action(‘admin_menu’, ‘cc_plugin_menu’); in the wrong spot. I moved it into the cc_plugin_menu function and it seems to save OK now.

    Here’s the updated code:

    add_action('admin_menu', 'cc_plugin_menu');
    
    function register_mysettings() {
        register_setting( 'cc_options', 'cc_cc_email' );
    }
    
    function cc_option_page() {
        ?>
        <div class="wrap">
        <h2>CC Comments Options</h2>
        <p>Welcome to the CC comments plugin. here you can edit the email(s) to CC your comments to.</p>
        <form method="post" action="options.php" id="cc-comments-email-options-form">
            <?php settings_fields( 'cc_options' ); ?>
            <?php do_settings_sections( 'cc_options' ); ?>
            <h3><label for="cc_cc_email">Eamil to send CC to:</label>
            <input type="text" id="cc_cc_email" name="cc_cc_email" 
                    value="<?php echo esc_attr(get_option('cc_cc_email')); ?>" /></h3>
            <p><input type="submit" name="submit" value="Save Email" /></p>    
        </form>
        </div>
        <?php 
    } 
    
    function cc_plugin_menu(){
        add_options_page('CC Comments Settings','CC Comments','manage_options','cc-comments-plugin','cc_option_page');
        add_action( 'admin_init', 'register_mysettings' );
    }