[wp-hackers] Pseudo-Cron

Otto otto at ottodestruct.com
Fri Sep 21 15:54:18 GMT 2007


On 9/21/07, Jeremy Visser <jeremy.visser at gmail.com> wrote:
> You do? Heck, I've been trying to understand it for 3 months now and
> still haven't succeeded in even scheduling _anything_. That makes me
> feel really awful. :(

Maybe an example would be useful.

Basic one time event:

function do_this_once() {
// do something
}
add_action('my_one_timer','do_this_once');
wp_schedule_single_event(time()+60, 'my_one_timer');

And that's it. That will schedule your one time event to run in one
minute from "now".

Basic repeating event:
function do_this_hourly() {
// do something
}
add_action('my_hourly_event','do_this_hourly');
wp_schedule_event(time()+60, 'hourly', 'my_hourly_event');

Pretty straightforward. Of course, you don't want to run this
directly, you want it to only schedule once, probably on plugin
activation. If you have it run every time, then you start scheduling
tons of stuff over and over again.


More information about the wp-hackers mailing list