• Skip to main content
  • Skip to primary sidebar

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network

Fix WordPress Capabilities.php Fatal Error

March 7, 2014 By Victor M. Font Jr.

Fix Bugs
Public Domain Image from Pixabay.Com

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.

Once you modify a WordPress core file, you'll have to keep applying the fix 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.

The Fix

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:

include_once(ABSPATH . 'wp-includes/pluggable.php');

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.

  • 4shares
  • Facebook0
  • Twitter0
  • Pinterest0
  • LinkedIn4
  • Print
  • SMS0

Filed Under: Code Snippet, Computers and Internet, How To, PHP, Programming, WordPress Tagged With: Bugs!, Code Snippet, Computers and Internet, How To, PHP, Programming, WordPress

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

Primary Sidebar

Shopping Cart

Books

  • Winning With WordPress Basics 2nd Edition Winning With WordPress Basics 2nd Edition $19.95
  • Ultimate Guide to the SDLC front cover The Ultimate Guide to the SDLC
    Rated 5.00 out of 5
    $74.95

Recent Articles

  • Modern Scam Defense: How Consumers and Businesses Can Recognize and Stop Email, Phone, and Text Fraud
  • How to Write a PRD So Dense It’s Technically a Novel
  • Top 5 Plugin Names That Scare Our Legal Department
  • When Agile Meets Our 3-Year Waterfall Roadmap: A Love Story
  • Why Our Enterprise Needs 27 Stakeholders to Approve a Button Color Change

Top 10 Article Categories

Best Practice Code Snippet Computers and Internet Genesis How To Leadership Programming Servant Leadership Tutorial WordPress

 
We only use analytical cookies on our website that allow us to recognize and count the number of visitors, but they do not identify you individually. They help us to improve the way our website works. By clicking Accept you, agree to cookies being used in accordance with our Cookie Policy.