wp_delete_user() fails during a wordpress scheduled job
-
I have a plugin that deletes all users from a WordPress installation. The plugin registers a new menu page and when a button is clicked it deletes the users. Here is my code:
$blogusers = get_users('blog_id=' . $GLOBALS['blog_id'] . '&orderby=nicename'); foreach ($blogusers as $userToDelete) { wp_delete_user((integer)$userToDelete->ID); } }
The above deletes all of the users (except admin) no problem. However, when I put the code into a hook and schedule it, if fails on the first wp_delete_user() code.
wp_schedule_single_event( time() + 1, 'hook_name' );
Any reason why you can’t make that call within a scheduled job but it runs fine outside of one?
Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘wp_delete_user() fails during a wordpress scheduled job’ is closed to new replies.