I have tried the following two approaches, each resulting that the cronjob gets added over and over again, until I remove the code. I literally had it scheduled hundreds of times...

    wp_schedule_event(time(), '30min', 'send_order_surveys');

   wp_schedule_event(time(), '30min', 'send_order_surveys');

What am I doing wrong?

1 Answer 1


Well, I found the answer in the actual documentation: https://developer.wordpress.org/reference/functions/wp_next_scheduled/

in form of a comment by "ub3rst4r":

Note the $args parameter! Not specifying the $args parameter in wp_next_scheduled but having $args for wp_schedule_event will cause many events to be scheduled (instead of just one).

Bad Example:

if ( ! wp_next_scheduled( 'myevent' ) ) { // This will always be false
    wp_schedule_event( time(), 'daily', 'myevent', array( false ) );

Good Example:

$args = array( false );
if ( ! wp_next_scheduled( 'myevent', $args ) ) {
    wp_schedule_event( time(), 'daily', 'myevent', $args );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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