Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current_user_can before plugins_loaded #7

Closed
Soean opened this issue Feb 7, 2017 · 3 comments
Closed

current_user_can before plugins_loaded #7

Soean opened this issue Feb 7, 2017 · 3 comments

Comments

@Soean
Copy link
Contributor

Soean commented Feb 7, 2017

If I call intervention('remove-update-notices'); I get an error.

Call to undefined function wp_get_current_user()

This is because the current_user_can() check is to early.

The only prerequisite for current_user_can() is an existing wp_get_current_user(). The latter is defined in pluggable.php, so you can use it after plugins_loaded.

source: http://wordpress.stackexchange.com/questions/198185/what-is-valid-timing-of-using-current-user-can-and-related-functions

@darrenjacoby
Copy link
Owner

I'm not able to reproduce this, does 4517f24 fix it for you?

Can we use admin_init rather than admin_menu for the action?

@Soean
Copy link
Contributor Author

Soean commented Feb 7, 2017

No, the pull request is not related to this. Its another issue.
I try to reproduce this in an other installation.

@Soean
Copy link
Contributor Author

Soean commented Feb 7, 2017

My function call was in a plugin without an action hook. So, now with an init hook it works, thanks...

@Soean Soean closed this as completed Feb 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants