I am trying to build a class to make the job off adding new settings easier. The trouble I am having is that, although I have traced the variable through all of it's stages, the string 'manage_options' doesn't seem to grant admin the right to amend and option. I keep getting "You do not have sufficient permissions to access this page." when I try access the new settings page.
Here is a heavily simplified version of the class, the creation function and its action hook.
class optionObject{
var $user_level = 'manage_options';
function add_page() {
add_options_page(menu_page_title, page_title, $this->user_level, menu_slug, array(&$this, 'do_page'));
}
function do_page(){
//do stuff to display page
}
}
function test_options(){
$options = new optionObject();
add_action('admin_menu', $options->add_page());
}
add_action('admin_init', 'test_options' );
Unedited Version here
admin_menu
is set up wrong. It should beadd_action('admin_menu', array($options, 'add_page'))
. Currently, you immediately execute the$options->add_page()
function in theadmin_init
hook, which might be too early.