I'm using the following snippet to add a menu item:

<?php
add_menu_page(
    'Foo Server',
    'Foo Server',
    'manage_options',
    'foo-server',
    array('Class', 'method')
);
?>

Fine, it's displayed. But clicking on it returns:

You do not have sufficient permissions to access this page.

I really don't know what to do.

Any idea? Thanks

UPDATE: Problem fixed. I was registering the menu using the wrong hook:

add_action('admin_init', 'function that runs the above code!');

must be:

add_action('admin_menu', 'function that runs the above code!');

Thanks.

link|improve this question
1  
Are you logged in with an administrator account? – GavinR Aug 3 '11 at 23:04
Yes, I am. Thanks. – thom Aug 4 '11 at 0:04
1  
Post your Update as Answer and mark it as solution in the following days. Else it would stay open forever. – kaiser Aug 4 '11 at 20:10
feedback

3 Answers

Do your WordPress Database Tables use wp_ as a prefix? I've read several articles that using a different prefix can cause the permissions error.

Source:

http://wordpress.org/support/topic/you-do-not-have-sufficient-permissions-to-access-this-page-45

http://beconfused.com/2007/how-to-solve-you-do-not-have-sufficient-permissions-to-access-this-page-in-wordpress/

link|improve this answer
I've read about something like that. I'll take a look, thanks. – thom Aug 4 '11 at 0:06
*************************************************************** Hey what's up with the down vote? Maybe the person that down voted the answer should post why they decided to give me a negative mark. I think it should be required. If you don't "share your brilliance", then your not helping anyone. Everyone has to start somewhere. I always try to help others not just be a prick to those that know less than me. ********************************************* – Jeremy Jared Aug 4 '11 at 11:56
I've tried both links. This doesn't work for my case. Thank you. – thom Aug 4 '11 at 19:33
@Jeremy Jared - Don't get upset. I voted it to zero again. I'm more angry about how this Q was asked and how the solution appeared... – kaiser Aug 4 '11 at 20:11
feedback

Hook into 'admin_menu' to register menu pages. And next time prepare your question better.

link|improve this answer
feedback

If you're calling this from inside a Php Class, then you're using the wrong syntax:

add_menu_page(
    'LiveHelp Server',
    'LiveHelp Server',
    'manage_options',
    'livehelp-server',
    // Call the  the method/function from inside a class
    array( __CLASS__, 'method_name' )
    // Another way to call the method/function from inside a class
    array( &$this, 'method_name' )
    // Another way to call the method/function from inside a class
    ClassName::method_name
);

Be sure that your method/function is really named method() (which is a bad idea). Else it won't work.

I guess you're simply calling it from inside a function, so it's enough to name the callback function (without a class).


Note: If you need further assistance, read about classes and functions on php.net. The Q itself is not really a Wordpress Q.

link|improve this answer
I'm not using the same class to do that! It's another class. I really know how call_user_func acts. Thank you very much. – thom Aug 4 '11 at 0:05
Maybe you want to provide your whole code? – kaiser Aug 4 '11 at 2:19
Please take a look at my update. Fixed. Thanks. – thom Aug 4 '11 at 19:51
Sorry Kaiser, it was me. I guessed it was you that down-voted my answer. I've see you've responded to my reply concerning the down-vote. I don't want you to misunderstand me. I have no problem with being down-voted, but I stand by what I posted. If you are going to criticize then it should be constructive criticism. I'm sure you were taught that somewhere in your design career. I wasn't upset for the negative vote, just that you didn't take the time to explain why. I see that a lot here, and it really makes the "down-voter" seem arrogant and as I said doesn't really help anyone but themselves. – Jeremy Jared Aug 5 '11 at 0:17
Oh, but I was the one who downvoted the OP. Not providing code is fishing in the dark. And that's not kool. – kaiser Aug 5 '11 at 0:33
show 2 more comments
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.