Title: Call to undefined function wp_get_current_user()
Last modified: August 30, 2016

---

# Call to undefined function wp_get_current_user()

 *  Resolved [Sii Cockerill](https://wordpress.org/support/users/designtwelve/)
 * (@designtwelve)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/)
 * There’s a PHP Error message:
 * E_ERROR: Call to undefined function wp_get_current_user()
 * Stack trace:
    in current_user_can called at /…./wp-includes/capabilities.php (
   1387) …/plugins/wp-simple-firewall/icwp-plugin-controller.php (843) …/… … in 
   ICWP_WPSF_FeatureHandler_Base_V3::action_doFeautureShutdown
 * [https://wordpress.org/plugins/wp-simple-firewall/](https://wordpress.org/plugins/wp-simple-firewall/)

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/page/2/?output_format=md)

 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6474853)
 * when and where does this occur, and can you provide the full stack trace?
 *  Thread Starter [Sii Cockerill](https://wordpress.org/support/users/designtwelve/)
 * (@designtwelve)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6474861)
 * Hi Paul,
 * I can’t be exactly sure – the error is being reported via New Relic on my client’s
   server.
 * I’ll install your plugin locally, allow errors and see what more I can find out
   for you.
 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475035)
 * Cool… the more stuff you can share on this, the better. This isn’t being reported
   anywhere else, but I can probably solve it with some checks for the function 
   anyway.
 *  Thread Starter [Sii Cockerill](https://wordpress.org/support/users/designtwelve/)
 * (@designtwelve)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475105)
 * Hi Paul,
 * Here’s the full stack trace.
 * Error message
    E_ERROR: Call to undefined function wp_get_current_user() Sample
   stack trace in current_user_can called at /var/www/website/blog/wp-includes/capabilities.
   php (1387) …w/website/blog/wp-content/plugins/wp-simple-firewall/icwp-plugin-
   controller.php (843) …website/blog/wp-content/plugins/wp-simple-firewall/src/
   features/login_protect.php (54) …ar/www/website/blog/wp-content/plugins/wp-simple-
   firewall/src/features/base.php (534) …ar/www/website/blog/wp-content/plugins/
   wp-simple-firewall/src/features/base.php (232) in ICWP_WPSF_FeatureHandler_Base_V3::
   action_doFeatureShutdown called at ? (?) in call_user_func_array called at /var/
   www/website/blog/wp-includes/plugin.php (496) …w/website/blog/wp-content/plugins/
   wp-simple-firewall/icwp-plugin-controller.php (623) in ICWP_WPSF_Plugin_Controller::
   onWpShutdown called at ? (?) in call_user_func_array called at /var/www/website/
   blog/wp-includes/plugin.php (496) in do_action called at /var/www/website/blog/
   wp-includes/load.php (613) in shutdown_action_hook called at ? (?)
 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475106)
 * How often does this error occur? Is it every page load? Do you know the page 
   that’s been loading when it happens?
 *  Thread Starter [Sii Cockerill](https://wordpress.org/support/users/designtwelve/)
 * (@designtwelve)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475107)
 * The logs show the same error on these pages:
 * index.php
    /blog/wp-comments-post.php /blog/wp-login.php /blog/xml-rpc.php /blog/
   wp-admin/profile.php /blog/wp-admin/admin-ajax.php /blog/wp-admin/index.php /
   blog/index.php
 * Index is getting the most hits, but it seems that it is every page load.
 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475108)
 * This error is very strange:
 * – wp_get_current_user() is defined in pluggable.php
    – pluggable.php is included
   in wp-settings.php right after plugins are loaded. – that means, for pluggable.
   php to not be loaded, something serious has gone wrong, since it’s core to the
   WordPress page load. – This means our plugin has been loaded and then the PHP
   process is being shutdown before the pluggable.php file is processed. – The error
   is occuring on PHP shutdown i.e. there’s a wp_die() or die() being called. – 
   This points to one of your other plugins shutting down the PHP process before
   pluggable.php gets included.
 * Can you try deactivating your plugins, one at a time, to find out which one is
   shutting it down early?
 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475109)
 * It can’t be every page load because then your site would never be loading – since
   it’s shutting down even before plugins are loaded.
 *  Thread Starter [Sii Cockerill](https://wordpress.org/support/users/designtwelve/)
 * (@designtwelve)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475110)
 * Thanks Paul,
 * There’s a plugin called User Role Editor that allows management of user capabilities.
   
   From the look of the error, that could be culpable… difficult to switch that 
   off on the live site though.
 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475114)
 * Worth pointing the author to this forum post. There’s not a lot that I can do
   on my plugin to cater for that error because the error is happening so early 
   on.
 * They need to better utilize hooks if they’re going to kill the process. This 
   ensures that, at the very least, pluggable.php have been loaded. If they put 
   in their die() within “plugins_loaded”, that would solve the issue since by then,
   pluggable has been loaded.
 *  Thread Starter [Sii Cockerill](https://wordpress.org/support/users/designtwelve/)
 * (@designtwelve)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475115)
 * Thanks Paul,
 * First thing I’ll do is try and prove that User Role Editor is the culprit.
 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475117)
 * Cool, that’s the first step – find the cause of the shutdown.
 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475178)
 * Any luck with this?
 *  Thread Starter [Sii Cockerill](https://wordpress.org/support/users/designtwelve/)
 * (@designtwelve)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475192)
 * Hi Paul,
 * Unfortunately not – the errors continued even with User Role Editor disabled.
   
   I’ve tested the site locally and see no errors in the log when I browse the normal
   site pages.
 * In the live server logs, there are fatal errors throw several times per minute,
   but none of them say which script caused the error to be thrown. They occasionally
   list a referrer, but if I try those URLs myself, no PHP error is thrown.
 * It’s quite odd. I’m wondering if it’s bot activity… but even then, that doesn’t
   help use figure out what’s causing it.
 * I need to be able to see the errors being generated on my local or staging server,
   in order to then disable the plugins one by one to find the problem.
 * Do you have any ideas how to explore the error logs further to work out what 
   produces the error?
 *  Thread Starter [Sii Cockerill](https://wordpress.org/support/users/designtwelve/)
 * (@designtwelve)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/#post-6475194)
 * I’ve tailed the live error log and access log simultaneously and reviewed the
   URLs that seem to cause the errors.
 * Visiting those URLs doesn’t replicate the issue, so I’m pretty much at a loss.

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/page/2/?output_format=md)

The topic ‘Call to undefined function wp_get_current_user()’ is closed to new replies.

 * ![](https://ps.w.org/wp-simple-firewall/assets/icon-256x256.png?rev=3054572)
 * [Shield: Blocks Bots, Protects Users, and Prevents Security Breaches](https://wordpress.org/plugins/wp-simple-firewall/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-simple-firewall/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-simple-firewall/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-simple-firewall/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-simple-firewall/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-simple-firewall/reviews/)

## Tags

 * [Coding](https://wordpress.org/support/topic-tag/coding/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 17 replies
 * 2 participants
 * Last reply from: [Sii Cockerill](https://wordpress.org/support/users/designtwelve/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-wp_get_current_user-3/page/2/#post-6475244)
 * Status: resolved