WordPress Plugin Error Call to undefined function wp_get_current_user
- Article
- Comment
WordPress Plugin Error Call to undefined function wp_get_current_user. If you have the problem of using the User functions like the get_current_user and get_user_by_id and get_current_userinfo. You need to understand that there are two reasons for the issue.
The very first one is file doesnot included properly, either the function doesnot comes under the WordPress hooks. Else you may included the file double times.
The second reason is, the pluggable class. I mean, there is a class which supports you to perform the Core functions on the plugin. Just include the following code to get activate these functions.
<?php if(!function_exists('wp_get_current_user')) { include(ABSPATH . "wp-includes/pluggable.php"); } ?>
The above code may help you, If it doesnot help you to get working on the custom functions. Try one more trick, it may help you to solve your issues.
<?php include(ABSPATH.'wp-blog-header.php'); ?>
This will be an alternative way to connect all wordpress core functions again with you custom plugin.