[wp-trac] [WordPress Trac] #25175: WPMU schedule doesn't work with some functions

WordPress Trac noreply at wordpress.org
Thu Aug 29 05:40:06 UTC 2013


#25175: WPMU schedule doesn't work with some functions
--------------------------+-----------------------------
 Reporter:  Looimaster    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Here's a simple event that is scheduled to be executed daily. It executes
 `delete_old_users()` function daily.

 {{{
 function delete_old_users() {
     $old_users = get_site_option( 'old_users' ); // at this point it works

     foreach ( $old_users as $user_id => $expiration_time ) {
         if ( $expiration_time <= gmmktime() ) {
             wpmu_delete_user( $user_id ); // here it stops working
         }
     }
     return;
 }
 add_action( 'delete_old_users_daily', 'delete_old_users' );


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

 `old_users` is an `array(ID => timestamp_when_registered)` (I know that
 each blog has registration date and this script will be improved to use
 that instead).

 Error when WP_DEBUG is enabled:
 {{{
 [24-Aug-2013 16:28:29] 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
 }}}

 Theoretically, it should work, am I right? Or is it my mistake? I also
 tried a hook name without underscores but it didn't help.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25175>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list