[wp-hackers] Pseudo-Cron

Otto otto at ottodestruct.com
Sun Sep 23 05:45:48 GMT 2007

Clearly these need to be documented, since everybody gets them wrong...

If you schedule any event, even a recurring one, wp_unschedule_event
will get rid of it. Completely. Even recurrances.

If you schedule the same event twice, wp_clear_scheduled_hook will get
rid of both of them. It's also somewhat simpler to use (no need to get
timestamp of next scheduled event).

This is because a recurring event only actually exists once: The next
time. When it runs, it's rescheduled for the next event just before it
actually executes. That's how recurring events work.

In short, you probably always want to use wp_clear_scheduled_hook to
get rid of an event. The only reason you ever want to use
wp_unschedule_event is if you have a complex set of events and want to
be certain that you get rid of get the exact one you want to get rid

On 9/22/07, Matt <speedboxer at gmail.com> wrote:
> On 9/22/07, Omry Yadan <omry at yadan.net> wrote:
> >
> > without know ANYTHING about the API, I am guessing that you need to use
> > wp_unschedule_event, and that
> >
> > wp_clear_scheduled_hook is used internally to notify listeners of
> > unschedule events.
> >
> I tried it out by checking if wp_next_scheduled_event was the cron. It turns
> out that you should you wp_clear_scheduled_hook if you want to completely
> get rid of a recursive cron. I think wp_unschedule_event just unschedules
> the next time it's supposed to run, but it will continue to run after that
> one that's been "skipped".
> --
> Matt (speedboxer at gmail.com)
> http://mattsblog.ca/ | http://livemp.net/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list