Title: Fatal error: Call to undefined function wp_get_current_user
Last modified: August 19, 2016

---

# Fatal error: Call to undefined function wp_get_current_user

 *  [David Gard](https://wordpress.org/support/users/duck_boy/)
 * (@duck_boy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/fatal-error-call-to-undefined-function-wp_get_current_user-3/)
 * Hey all,
 * Got an odd error going on at the moment –
 * I have a plugin that uses the following code –
 *     ```
       if(current_user_can('manage_options')){
       	add_action('admin_menu', 'add_dd_options_menu');
       	add_action('admin_head', 'dd_options_header');
       }
       ```
   
 * But this plugin generates this error –
 * > Fatal error: Call to undefined function wp_get_current_user() in C:\wamp\www\
   > website\test\wp-includes\capabilities.php on line 1059
 * Changing it to the below so that I am not checking capabilities works fine –
 *     ```
       //if(current_user_can('manage_options')){
       	add_action('admin_menu', 'add_dd_options_menu');
       	add_action('admin_head', 'dd_options_header');
       //}
       ```
   
 * But the strangest thing is that this statement in a different file works fine,
   even when checking capabilities –
 *     ```
       if(current_user_can('manage_options')){
       	require_once('dd_includes/dashboard_widgets.php');
       	add_action('admin_menu', 'remove_rubbish_dashboard_boxes');
       }
       ```
   
 * Does anybody know if I am missing anything, or if i have made a very silly mistake
   with the code?
 * Any help apprciated.
 * Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Michael Fields](https://wordpress.org/support/users/mfields/)
 * (@mfields)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/fatal-error-call-to-undefined-function-wp_get_current_user-3/#post-1659947)
 * I’ve ran into similar problems in the past. I think that this happens because_(
   in the first instance)_ you are using `current_user_can()` before all appropriate
   files have been loaded. I’m guessing that the _“code in another file”_ is hooked
   into WordPress at a later time in script execution. I try to hook everything 
   at `wp_loaded` or later if possible.
 *  [Gisha James](https://wordpress.org/support/users/gjames/)
 * (@gjames)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/fatal-error-call-to-undefined-function-wp_get_current_user-3/#post-1659967)
 * Try by adding require_once(‘pluggable.php’);
 *  Thread Starter [David Gard](https://wordpress.org/support/users/duck_boy/)
 * (@duck_boy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/fatal-error-call-to-undefined-function-wp_get_current_user-3/#post-1660038)
 * Thanks Gisha, that does work, supporting Michaels suggestion that not all the
   files have been called when that plugin is being loaded. Not sure why though,
   as I have another pluging that is based on the same template (obv calls different
   functions) and that works just fine.
 * Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Fatal error: Call to undefined function wp_get_current_user’ is closed
to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [David Gard](https://wordpress.org/support/users/duck_boy/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/fatal-error-call-to-undefined-function-wp_get_current_user-3/#post-1660038)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
