current_user_can on WordPress 3.1.1

You are calling the function too early. The functions.php is included before current_user_can() is defined. Never do anything before the hook 'after_setup_theme':

Example for the functions.php

add_action( 'after_setup_theme', array( 'WPSE_14041_Base', 'setup' ) );

class WPSE_14041_Base
{
    public static function setup()
    {
        ! isset ( $GLOBALS['content_width'] ) and $GLOBALS['content_width'] = 480;

        add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
        add_theme_support( 'automatic-feed-links' );

        add_theme_support( 'menus' );

        add_editor_style();

        add_custom_background();

        // You may use current_user_can() here. And more. :)
    }
}

Leave a Comment