Categories
Online Services WordPress

Solution for – Fatal error: Call to undefined function wp_get_current_user() in /wordpress/wp-includes/capabilities.php on line 1183

Solution for - Fatal error: Call to undefined function wp_get_current_user() in /wordpress/wp-includes/capabilities.php on line 1183
Solution for - Fatal error: Call to undefined function wp_get_current_user() in /wordpress/wp-includes/capabilities.php on line 1183

After the release of WordPress Data Guard Pro Plugin (Version 2.9), few users reported that they are getting the error like :

Fatal error: Call to undefined function wp_get_current_user() in C:\xampp\htdocs\wordpress\wp-includes\capabilities.php on line 1183

Solution:
If you run into the same problem, then there is a simple solution for it.

Just write the below code in wordpress/wp-includes/capabilities.php after ?php sign.

require_once("pluggable.php");

Now you will be able to load all the pages without any error.

So, What is the exact problem :
This problem arises when one of your plugin or theme file wants to get the user type (e.g. Administrator, Editor, Contributer, Author, Subscriber) either in form of a function or in form of variable.

For Example, the below code will generate the same error, if placed in a plugin file:

if(current_user_can('level_10')) {$user_is = 'Admin';}
else {$user_is = 'Not Admin'; }

So in such cases, you can include the pluggable.php file into capabilities.php file.

Note : You might bookmark this page for the future references, as after updating the wordpress, capabilities.php gets restored to default, and then you need to follow the same procedure again.

By William E. Goldston

William is a Web Enthusiast. He likes to post articles about almost every topic, and love to mess with the latest technological gadgets, so that he can share his experience with the whole world.

Leave a Reply

Your email address will not be published. Required fields are marked *