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') ) {</p>
<p>function wp_get_current_user() {<br />
global $current_user;<br />
get_currentuserinfo();<br />
return $current_user;<br />
}</p>
<p>}
Extend it to this:
if ( !function_exists('wp_get_current_user') ) {</p>
<p>function wp_get_current_user() {</p>
<p>// Insert pluggable.php before calling get_currentuserinfo()<br />
require (ABSPATH . WPINC . '/pluggable.php');</p>
<p>global $current_user;<br />
get_currentuserinfo();<br />
return $current_user;<br />
}</p>
<p>}
I can’t tell if you need require or require_once – all I can say is that both work fine.
The post ends here. Wanna leave a response? Have Your Say!
You can also subscribe to comments without commenting.
BTW: This post has comments.
Next post: Kitten Gets Owned
Previous post: Using Google Translation Service (Part II)
The above post was initially scribbled on January 28th, 2009 @ 17:15:17 +0100 (CET) and has been last modified on April 8th, 2009. It is filed under the category WordPress Stuff and has been tagged with the terms [error | function | get_currentuserinfo | plugin | troubleshooting | wordpress].
Trackback URI | Comments RSS | Permalink
- Pingback on 2009-08-04: Call To Undefined Function get_currentuserinfo() | Mar...
- Pingback on 2009-10-27: Gengo : comment résoudre l’erreur Call to undef...








Comment
#1
Thanks for this wonderful piece of information that saved me losing anymore hair and sleep. After inserting require (ABSPATH . WPINC . ‘/pluggable.php’); before wp_get_current_user() the code worked like a charm. Two days I scoured the WP Codex and the Web.
Comment
#2
Thanks for the info
A quick google search bought me here.