Since the upgrade to WordPress 3.6, my multi-site installation has been plagued with the following error:[28-Aug-2013 13:02:59 UTC] PHP Fatal error: Call to undefined function wp_get_current_user() in /public_html/wp-includes/capabilities.php on line 1281
First, the error occurred when I deactivated the NextGen Gallery plugin on http://www.fontlife.com/. Deactivating the plugin caused the error to rear its ugly head which causes the site to fail to load.
Next, it happened when I disabled open registration using the S2Member plugin on this site. Deactivating open registration caused the S2Member general options screen to lose it's formatting and appear as one giant text file. When I attempted to visit the site, the site failed to load displaying the above error message instead.
After researching the error, I found several references to a fix that most writers were unsure that it is the proper fix or not. The fix requires modifying the wp-includes/capabilities.php file. This is a WordPress core file. Modifying any WordPress core file is generally a big no-no, but in this case, adding a single line to capabilities.php fixes a multitude of sins. The problem with modifying a WordPress core file is that once you do, you'll have to keep doing it every time there's an update issued for WordPress.
There are references to this problem that extend back to the release of WordPress 3.0.1. At least one WordPress Developer, Andrew Nacin, mentioned in a 2011 post that he thought the issue began with https://core.trac.wordpress.org/changeset/15452, released on 07/21/10. In that post, Nacin says:
pluggable.php doesn't get loaded until after all plugins are loaded. This cripples a lot of functions that then rely on, directly or indirectly, wp_get_current_user(), among others.
We don't even load the current user until just before the init hook. Doing anything to the current user before the init hook will not work.
To apply the fix, you must comfortable with modifying a .php file. If you are not comfortable with this, stop now and ask someone who is for help.
Open capabilities.php in your favorite text editor and add the following line at the top of the file after the php opening tag:
Save the file and copy it back up to your wp-includes folder. That's all there is to it, until the next WordPress update that is. Anytime there is a new WordPress release, there's a chance that they'll release a new capabilities.php. You'll have to keep checking your error_log and make this change for each subsequent WordPress update unless you can find the plugin(s) that are calling wp_get_current_user() too early.