Tech from Hel
Helene's ramblings on Wordpress, jQuery and other web technologies.
rss
twitter
  • About
  • Projects

A Fine Fix for “get_currentuserinfo undefined”

no comments
Posted on Mar 24 2010 by helene

How to Fix the Fatal Error “get_currentuserinfo() undefined” in WordPress

If you write a WordPress plugin that calls the function “get_currentuserinfo()”, you should be aware that this could trigger the fatal error, “get_currentuserinfo undefined’, in some WordPress configurations. Depending on what your plugin does, this error could impact a WordPress site’s display, so it is important to prevent it from ever happening.

One fix (as published by several WP bloggers) is to edit your plugin to add the code, include "/wp-includes/pluggable.php", manually before you call “get_currentuserinfo()” (or other WordPress user functions). This methods works in most cases, but it runs the risk of causing an irreconcilable conflict with any membership or user management plugins that may be installed on the same site.

A better fix is to include a priority argument with your plugin hook function to make sure that it loads into WordPress after any membership/user management plugins and after “pluggable.php” loads. I found that a priority of “20″ is a high enough number to lower the priority to accomplish this. Ex:

add_action('plugins_loaded', 'load_my_plugin',20);

To use the above example, you should group all your plugin functions and any action or filter functions that contain “get_currentuserinfo()” together into a single hook function, “load_my_plugin()”. Then put “plugins_loaded”, “load_my_plugin” and the priority, “20″, as arguments for an ‘add_action()’ call to tell WordPress to load all plugins with standard (10) or higher priorities before your plugin and load “pluggable.php” module, thus avoiding any conflicts with membership/user-management plugins and “get_currentuserinfo() undefined” fatal errors.

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

  Tags: fatal error, get_currentuserinfo, wordpress Category: Blogging, Plugins

Leave a Reply

Click here to cancel reply.




Categories

  • Blogging
  • javascript
  • Miscellaneous
  • Multimedia
  • MySQL
  • Plugins

Recent Posts

  • WassUp Works Well with WP Widget Cache
  • CTRL+Z Undo: The Keyboard Shortcut You Can’t Do Without
  • A Fine Fix for “get_currentuserinfo undefined”
  • Optimize with MySQL Procedure Analyse
  • Sleeping with Javascript

Popular Posts

  • Horizontal Submenus for Wordpress Admin Plugins
  • Flv Videos in a Thickbox
  • YouTube Videos in a Thickbox
  • Sleeping with Javascript
  • Installing a More Secure Wordpress

Archives

Ads


  • About
  • Projects
Powered by Wordpress  |  Designed by WebTreats