Title: Using current_user_can breaks plugin
Last modified: August 19, 2016

---

# Using current_user_can breaks plugin

 *  Resolved [mrmist](https://wordpress.org/support/users/mrmist/)
 * (@mrmist)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/using-current_user_can-breaks-plugin/)
 * Hello
 * I’m trying to use
    `if (current_user_can('manage_options'))` in my plugin
 * But when I do I get this error ..
 * >  Fatal error: Call to undefined function wp_get_current_user() in …./blog/wp-
   > includes/capabilities.php on line 447
 * Any ideas what I have to do to make current_user_can work in my plugin?

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

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [17 years, 10 months ago](https://wordpress.org/support/topic/using-current_user_can-breaks-plugin/#post-818998)
 * You cannot use wp_get_current_user until pluggable.php has loaded, which means
   you need to defer that usage until the plugins_loaded action, at least.
 *  Thread Starter [mrmist](https://wordpress.org/support/users/mrmist/)
 * (@mrmist)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/using-current_user_can-breaks-plugin/#post-819000)
 * Ok. I see what you mean but am not sure how to do it?
 * Basically I have a line in the plugin that adds a link on the dashboard, but 
   I only want the link to appear if the user is an admin.
 * add_action(‘activity_box_end’, ‘dm_bblr_activitybox’);
 * is what I’m doing.
 * Does what you say mean that I can’t do any checks around the user permissions
   in my plugin?
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [17 years, 10 months ago](https://wordpress.org/support/topic/using-current_user_can-breaks-plugin/#post-819109)
 * No, you can do user checks, but you can’t do them too early.
 * The question is when exactly are you doing this check? When the plugin just runs?
   Or in the dm_bblr_activitybox function?
 *  Thread Starter [mrmist](https://wordpress.org/support/users/mrmist/)
 * (@mrmist)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/using-current_user_can-breaks-plugin/#post-819141)
 * Ahh the light begins to dawn. I was attempting to do it when the plugin runs.
   I’ll see if I can move the check. 🙂
 *  [Ryan Hellyer](https://wordpress.org/support/users/ryanhellyer/)
 * (@ryanhellyer)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/using-current_user_can-breaks-plugin/#post-819399)
 * Thanks Otto 🙂
 * For anyone confused by his instructions (I was for a start). You need to move
   the check to the point in your plugin/theme which does the check. Ie: If you 
   checking before loading something into wp_foot, you need to add the check around
   the chunk of code which actually modfies wp_foot. Otherwise pluggable.php has
   not loaded yet.
 * Actually, I don’t think my instructions are much better. But hopefully someone
   will be able to decipher it :p

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

The topic ‘Using current_user_can breaks plugin’ is closed to new replies.

## Tags

 * [current_user_can](https://wordpress.org/support/topic-tag/current_user_can/)

 * 5 replies
 * 3 participants
 * Last reply from: [Ryan Hellyer](https://wordpress.org/support/users/ryanhellyer/)
 * Last activity: [17 years, 1 month ago](https://wordpress.org/support/topic/using-current_user_can-breaks-plugin/#post-819399)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
