[wp-hackers] Roles/Capabilities added, but only active on next page load after activation?

Tobias Bäthge wp-hackers at tablepress.org
Sat Dec 8 22:16:57 UTC 2012


I'm currently running into a small problem with user roles and custom
I've written a demo plugin that shows the issue (on both WP 3.4 and
trunk): https://gist.github.com/4242194

To reproduce:
- Go to "Plugins" in the admin menu.
- Activate test "Menu Cap Test" plugin
- You will see the yellow "Plugin activated." admin notice at the top.
- BUT: You will not see the "MCT plugin" entry at the bottom of the admin menu!
You will only see that entry after loading any other page, e.g. by
clicking any entry in the admin menu.

What am I doing wrong?


P.S. You will only be able to observe this on the very first
activation of the plugin, as the cap is already added on subsequent
activations. Thus, when testing, the cap should be removed again
before activating the plugin.

More information about the wp-hackers mailing list