On this answer, there was this final comment

For future readers, Roland's issue was a hook priority issue. Changing priority from 10 to 11 fixed it in his case

The answer seems already closed, so I couldn't comment, but why/how would a hook priority make an admin menu work or produce a permission error?

You do not have sufficient permissions to access this page.

  • That you can't comment seems to be a Q of "how many rep points are needed?".
    – kaiser
    Commented Feb 7, 2012 at 1:03
  • I am generally able to comment. I think the question was simply closed or something.
    – Yoav Aner
    Commented Feb 7, 2012 at 8:29

1 Answer 1



All hooks & filters have a priority. Those are used to order the functions that are attached to hooks. By default the priority is 10.

As the default is 10, there's a big chance that your filter/action gets hooked too early and therefore can't affect the actual output.


  1. Imagine that the plugin hooks it's bootstrap into the 'admin_init' hook to add something that needs permissions to access. Inside that bootstrap it hooks something to the (fictional) 'fantastic_hook'.
  2. Imagine that you hook some extension of a plugin to the 'after_theme_setup' hook. There you add some function to the (fictional) 'fantastic_hook' too.

So the result of print_r( $GLOBALS['wp_filter']['fantastic_hook'] ); would be the following:

[10] Array => ['fantastic_hook']
        Array => ['your_custom_extension']
        Array => ['the_plugin_bootstrap']

As your extension and the bootstrap run both at priority 10. But yours got added first and will therefore run first. And there comes the problem...

About the menu items

The admin menu works pretty similar: You have a priority (the (sub-)array index) that cares about ordering and placing the menu items.

// Example for your functions.php:
function dump_filters()
    $output = '';
    foreach ( array( $GLOBALS['menu'], $GLOBALS['submenu'] ) as $item )
        $output .= var_export( $item, false );
    echo "<pre>{$output}</pre>";
add_action( 'adminmenu', 'dump_filters', 999 );

Note: I wrote a pretty intense post about the menu order, where you can see how you'd reorder the menu and read a little bit about the behind-the-scenes of the menu and it's limitations.

  • "As the default is 10, there's a big chance that your filter/action gets hooked too early and therefore can't affect the actual output." - Why? or what's 'too early'? I see that in some plugins it appears to work just fine without explicitly setting the priority to higher. Also, the menu option does show, but it generates this weird and seemingly unrelated permission error... Otherwise, thanks for the link. I'll check it out.
    – Yoav Aner
    Commented Feb 7, 2012 at 8:28
  • 1
    Yes, you're able to add whatever stuff. Point is that other code runs later and (for example) permissions are set when the later code is run. So if you add yours earlier, then the permissions aren't in place and therefore fail. Second: If 2 functions hook into priority 10 at different times (they can't run simultaneously), then the one that gets triggered first, gets added first and therefore runs first. This is where the error comes from. So in case you aren't sure: Run your function later.
    – kaiser
    Commented Feb 7, 2012 at 8:46
  • Ok... I understand the solution, it evidently works. I'm not that sure I'm clear about the reason why it doesn't work without changing the priority, or why it produces a permission error where permissions/capabilities are set correctly on both places. I guess it's just one of many WP quirks.
    – Yoav Aner
    Commented Feb 7, 2012 at 9:01
  • Ok, I'll try to make it clear again and update the answer slightly.
    – kaiser
    Commented Feb 7, 2012 at 9:10
  • 1
    WordPress isn't known for beeing Debug Heaven ;)
    – kaiser
    Commented Feb 7, 2012 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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