I don't have permission to save the theme options I created myself?

Written by  on October 15, 2016 

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');
}

Category : Wordpress

Tags :