The MU forums have moved to WordPress.org

wp_get_current_user() error when using plugin (10 posts)

  1. Mattz
    Member
    Posted 16 years ago #

    Hi,

    I have tried to use the following plugin on a WPMU installation because most of the plugins work actually quite good on WPMU.

    It's the following plugin: Eshop http://www.quirm.net/page.php?id=39

    So far I get an error when I activate the plugin and every site on the MU install gives a 500 error on every page after that.

    The error that I get in my php logs is:

    PHP Fatal error: Call to undefined function wp_get_current_user() in /var/www/html/wp-includes/capabilities.php on line 446

    I have searched and seen more issues with exact the same error, but it should not be soemthing with the working of this plugin I have the idea.

    What could be wrong ?

  2. Trent
    Member
    Posted 16 years ago #

    Waiting as well for an educated answer here, but I am assuming that current users are called using a different method with WPMU than the plugins is trying to do. Maybe search through capabilities.php and find out what function is similar for calling the current user and then change the plugin to that function to test further.

    Trent

  3. Mattz
    Member
    Posted 16 years ago #

    Hi Trent,

    I think we should digg through the plugin to see a wp_get_current_user() but as a different function.

    So we should call wp_get_current_user(), but this is another function in the plugin.

  4. Mattz
    Member
    Posted 16 years ago #

    Does someone has a clue for this ?

    I have the idea that it's not a major thing, the writer of the plugin was not able to find it also.

  5. Mattz
    Member
    Posted 16 years ago #

    I have the idea that this will not be a WPMU version :(

    Is this function really different or additional to WPMU ?

  6. RavanH
    Member
    Posted 16 years ago #

    Same happens with the YAK e-commerce plugin...

    In the file capabilities.php i find the offending call:
    `// Capability checking wrapper around the global $current_user object.
    function current_user_can($capability) {
    $current_user = wp_get_current_user();

    if ( empty($current_user) )
    return false;

    $args = array_slice(func_get_args(), 1);
    $args = array_merge(array($capability), $args);

    return call_user_func_array(array(&$current_user, 'has_cap'), $args);
    }`

    So i guess this is a internal WPMU issue brought up by a call to the function current_user_can...

  7. RavanH
    Member
    Posted 16 years ago #

    Found an old ticket about this on http://trac.mu.wordpress.org/ticket/384 but it has been closed without any resolution. I wonder why...

  8. RavanH
    Member
    Posted 16 years ago #

    Strange thing this... Since the function IS defined! Found the following in wp-includes/pluggable.php :

    <code>if ( !function_exists('wp_get_current_user') ) :
    function wp_get_current_user() {
    	global $current_user;
    
    	get_currentuserinfo();
    
    	return $current_user;
    }
    endif;</code>

    Is the library file not included properly?

  9. RavanH
    Member
    Posted 16 years ago #

    OK, this seems to do the trick:

    In file wp-includes/capabilities.php add on line 2:
    require_once('pluggable.php');

    Now the eShop plugin can be activated... Let's see if it will function on MU !

  10. RavanH
    Member
    Posted 16 years ago #

About this Topic