Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I created an option panel following a tutorial.

But each time I try to save the settings I get the following:

You do not have sufficient permissions to access this page.

Any suggestions to fix this?

(Not sure if this helps but I'm using Wordpress 3.1.2)

EDIT:

I don't have the permission issue if I place the code directly in the functions.php file in my theme folder.

I have the file in functions/custom-functions.php. I have to change the 'header Location,' not sure how:

function mytheme_add_admin() {
    global $themename, $shortname, $options;

    if ( $_GET['page'] == basename(__FILE__) ) {
        if ( 'save' == $_REQUEST['action'] ) {
            foreach ($options as $value)
                update_option( $value['id'], $_REQUEST[ $value['id'] ] );

            foreach ($options as $value) {
                if( isset( $_REQUEST[ $value['id'] ] ) )
                    update_option( $value['id'], $_REQUEST[ $value['id'] ]  );
                else
                    delete_option( $value['id'] );
            }
            header("Location: admin.php?page=functions.php&saved=true");
            die;
        }
        else if ( 'reset' == $_REQUEST['action'] ) {
            foreach ($options as $value)
                delete_option( $value['id'] );

            header("Location: admin.php?page=functions.php&reset=true");
            die;
        }
    }
    add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin');
}
share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You're adding the menu page using the "administrator" role. Is the account you're using an administrator?

Note:

1) You should be using an appropriate capability, rather than a user role. Generally, the appropriate capability for editing Theme options is edit_theme_options.

2) There is a known bug with WordPress, in that currently, manage_options is required for the form submit on options.php, which is used by Theme settings pages. This is only an issue for user roles below editor, and will hopefully be fixed in 3.2 or 3.3.

3) If this is a public Theme, you should be using add_theme_page() (which adds a submenu to the "Appearance" menu), rather than add_menu_page() (which adds a top-level menu page).

4) That tutorial is considerably out of date.

share|improve this answer
    
Thanks for helping again. Can you give me an example for 1)? How would that code look like (Which lines I have to replace)? –  janoChen May 9 '11 at 2:16
2  
@janoChen: the third argument in add_menupage() currently is 'administrator'; change it to 'edit_theme_options'. –  Chip Bennett May 9 '11 at 12:03
add comment

I know I'm late on this issue... but still wish to keep my answer submitted in hope that someone may discover this thread in Google Search. :-)

You need to make two changes in your code...

  1. Change the third argument of add_menu_page from "administrator" to "edit_theme_options"
  2. Chage header("Location:") code line to...

    header("Location: admin.php?page=" . basename(FILE) . "&saved=true");

Please make similar change for Reset. Oh well, I'm sure you will make the corrections in "basename" stuff as this forum's HTML may not show the "FILE" thing in ( ) correctly.

I hope this helps.

Cheers,

Ruturaj.

share|improve this answer
add comment

Your Answer

 
discard

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.