0

From the fm:

NOTE: If you're running into the "You do not have sufficient permissions to access this page." message in a wp_die() screen, then you've hooked too early. The hook you should use is admin_menu.

I am able to create menu items and submenus from hooks much earlier than admin_menu eg: plugins_loaded. In fact, it seems to work without any hook, at all, straight outta functions.php. WP 4.0.1. So, what gives? Is this old info?

1 Answer 1

1

I am not sure how are you ending up with these results. The earliest hook it should work at is roughly admin_init. Anything as early as load process (wp-settings.php, including function.php, plugins_loaded, and even init) should (and does in my installation) produce fatal error, because function definitions hadn't loaded yet.

The definition for these functions (wp-admin/includes/plugin.php) are only loaded after bulkd of core load (wp-load.php) is done.

In a nutshell documentation is correct and it's a mystery why it works in your case. It shouldn't, short of exotically customized core load process.

4
  • plugin.php seems to load before functions.php. I'm running a child theme of ET's Harmony theme. But just an unadulterated wp setup. Dec 6, 2014 at 21:00
  • Oh wierd... I tried it on another site, also child of Harmony theme, Fatal error: Call to undefined function add_menu_page() in C:blah/blah\www\wp-content\themes\Harmony_child\functions.php on line 24 Dec 6, 2014 at 21:46
  • auth_redirect seems to be the earliest you can hook. Arrg, so I have no idea why the other site works. Dec 6, 2014 at 21:51
  • Ahh... Redux framework includes plugin.php Dec 6, 2014 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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