Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm running WordPress 3.6, multisite. I have a plugin activated with this content (it's been simplified):

function prefix_delete_user() {
    $some_option = get_site_option( 'some_option' ); // at this point it works
    wpmu_delete_user( 2 ); // at this point it doesn't
    return;
}
add_action( 'delete_user_daily', 'prefix_delete_user' );

function setup_schedule() {
    if ( ! wp_next_scheduled( 'delete_user_daily' ) ) {
        wp_schedule_event( time(), 'daily', 'delete_user_daily');
    }
}
add_action( 'wp', 'setup_schedule' );

Every day, a new blog with an ID of 2 is registered and every day I would like to remove it but I'm getting the following error:

PHP Fatal error: Call to undefined function wpmu_delete_user() in /home/example/ftp/example.com/wp-content/plugins/expiration/expiration.php on line 96

I'm wondering why this might be happening?

When I'm calling do_action( 'delete_user_daily' ); manually, it works...

share|improve this question

1 Answer 1

Looks like ms.php file is not loaded for cron job. Try to add following line at the beginning of your plugin:

require_once ABSPATH . 'wp-admin/includes/ms.php';
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.