Marco Luthe Online! » WordPress Stuff » Call To Undefined Function get_currentuserinfo()
Call To Undefined Function get_currentuserinfo()
I just recently updated my WordPress plugins, and after I downloaded Maintenance Mode (v4.0) and uploaded it onto my WordPress blog, Filosofo Comments Preview threw an error that said:
Call to undefined function get_currentuserinfo()…
That was pretty odd, because both plugins worked fine before – now, after updating one of them, the other one threw an error.
After doing some research, I found this post on the WordPress support forum that says that get_currentuserinfo() is actually defined within pluggable.php which is loaded AFTER all plugins – that means that the function is not yet ready if you call it normally in your plugin.
I found the answer within the code of the Maintenance Mode plugin – you have to manually insert that pluggable.php using the require statement in php.
So, look for this code in Filosofo Comments Preview (should be line 638 in v1.5):
if ( !function_exists('wp_get_current_user') ) {
function wp_get_current_user() {
global $current_user;
get_currentuserinfo();
return $current_user;
}
Extend it to this:
if ( !function_exists('wp_get_current_user') ) {
function wp_get_current_user() {
// Insert pluggable.php before calling get_currentuserinfo()
require (ABSPATH . WPINC . '/pluggable.php');
global $current_user;
get_currentuserinfo();
return $current_user;
}
}
I can’t tell if you need require or require_once – all I can say is that both work fine.
Filed under: WordPress Stuff · Tags: error, function, get_currentuserinfo, plugin, troubleshooting, wordpress
2 Pingbacks/Trackbacks
-
Mohan
-
Mark











