Fix the error: get_currentuserinfo() is deprecated in WordPress

After updating to latest WordPress version 4.5 i stumbled over a lot of plugins which are throwing the error get_currentuserinfo() is deprecated. (One of the mentioned plugins is mailpoet 2.7.1 which is not updated, yet)

The exact error message is:

Notice: get_currentuserinfo is deprecated
since version 4.5! Use wp_get_current_user() instead.
in /srv/www/wordpress-develop/src/wp-includes/functions.php on line 3657

The meaning of this error is very easy. It tells you that one or more of your plugins are using the outdated function get_currentuserinfo(). The relevant plugins are still working but it’s highly likely that they plugin will stop working or will not working as expected at a later time point when WordPress removes that deprecated function. Deprecated messages are a warning to developers that specific functions should not be used any longer because they will be removed later. For now when you see that message you know that your plugin is only running in a kind of compatibility mode and the cause should be repaired as soon as possible.

Usually these error messages are a clear indication what plugin is causing the issue but the crux with deprecated messages is that they do not give us any hint which plugin is involved or where the error is happening exactly!
But wait, don’t we have exact line and even the name of the file (functions.php)?

Yes we have but this is only the line of the function which triggers the error for deprecated functions. That’s not the place where get_currentuserinfo () is used.

If you want to find out what plugin is causing it you have to deactivate one by one all your plugins until the deprecated message is gone or you follow a much easier attempt:

1. Install the query monitor plugin

2. Check out the admin bar notice and click on the highlighted warning:


3. The screen jumps to the detailed warning explanation:


4. The section Call Stack will tell you the exact location where get_currentuserinfo() is used.

To fix this issue just replace get_currentuserinfo() with wp_get_current_user() 

Et voila you are done!


Follow MashShare?