• Skip to main content

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

Call Us:

+1 919-604-5828

  • 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
You are here: Home / Code Snippet / Fix WordPress Capabilities.php Fatal Error

Fix WordPress Capabilities.php Fatal Error

By Victor M. Font Jr.
March 7, 20148 Comments

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

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.

Reader Interactions

VictorFont.com runs on the Genesis Framework

Genesis FrameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Check out the incredible features and the selection of designs. It's that simple—start using Genesis now!

Click here to download The Genesis Guide for Absolute Beginners (PDF - 1.4 MB)

Leave a Reply Cancel reply

Your email address and website will not be published. Required fields are marked *
Posting a comment means that you agree with and accept our Comment & Product Review Policy

Comments

  1. Hugo

    January 22, 2018 at 5:26 pm

    Awesome! Fixed just in few seconds :)

    Reply
  2. Aidan

    July 11, 2015 at 6:14 am

    All I did was to go into the cPanel’s File Manager, went to /public_html/wp-content/plugins and deleted the folder that the broken plugin was in… I tried yours too but that didn’t work for my configuration.

    Reply
    • allen jacques

      May 8, 2016 at 7:45 pm

      You are a genius! I’ve been working on this issue for several days and your solution fixed it and totally makes sense… sometimes the simplest solutions are the beast!

      Reply
    • Amidu Adebayo

      August 2, 2016 at 7:20 am

      Hi Aidan, you are indeed too much. I just did it the way say it and it worked and I have spent three days finding how to solve the problem. The most annoying of it all is that I informed my web host provider and told me to delete the whole wordpress installation and start not minding the time and efforts I have put into the site.
      Thanks a million

      Reply
  3. vejdani

    May 21, 2015 at 8:11 am

    Thank you so much.
    Even in wordpress 4.2.2 I still have this problem with s2member plugin.

    Reply
  4. iLen

    December 22, 2014 at 7:35 pm

    Thanks so much!

    Reply
  5. Scott R.

    December 11, 2014 at 8:31 pm

    Genius. Your fix got me back in to the admin panel so that I could remove the offending plugin.
    Thanks!

    Reply
    • Victor M. Font Jr.

      December 11, 2014 at 10:20 pm

      Glad I could help!

      Reply

Call: +1 919-604-5828

Send us an E-mail

Accessibility Statement | Affiliate Marketing Disclosure | Capability Statement

Cookie Policy | Comment & Product Review Policy | Privacy Policy | Site Map | Terms & Conditions

Copyright © 2003–2023 Victor M. Font Jr.

Return to top of page