WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 13 months ago

#23861 closed defect (bug)

Using current_user_can() inside a plugin causes a fatal error — at Initial Version

Reported by: PhilippH Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.1
Component: Plugins Keywords:
Focuses: Cc:

Description

I experienced that using the function current_user_can() causes an fatal error:
Fatal error: Call to undefined function wp_get_current_user() in /var/www/wp-includes/capabilities.php on line 1281

For reproducing the error:

or

  • add following line at the end of wp-content/plugins/hello.php:

-- echo current_user_can("switch_themes"); any capability causes the error

My environment:

  • Debian wheezy
  • apache2 & php5 & mysql from official package mirror

I also noticed that this error is caused by using user_can() inside a plugin. (with an other error message indeed)
After adding include("pluggable.php") to capabilities.php, the problem seems to be resolved!

Change History (0)

Note: See TracTickets for help on using tickets.