Codex tools: Log in
Contents |
Schedules a hook which will be executed once by the WordPress actions core at a time which you specify. The action will fire off when someone visits your WordPress site, if the schedule time has passed.
<?php wp_schedule_single_event( $timestamp, $hook, $args ); ?>
Note that scheduling an event within 10 minutes of an event of the same name will be ignored, unless you pass unique values for $args to each scheduled event. See Function_Reference/wp_next_scheduled for more information.
Attempts to schedule an event after an event of the same name and $args will also be ignored.
function do_this_in_an_hour() {
// do something
}
add_action('my_new_event','do_this_in_an_hour');
// put this line inside a function,
// presumably in response to something the user does
// otherwise it will schedule a new event on every page visit
wp_schedule_single_event(time()+3600, 'my_new_event');
// time()+3600 = one hour from now.
function do_this_in_an_hour( $arg1, $arg2, $arg3 ) {
// do something
}
add_action( 'my_new_event', 'do_this_in_an_hour', 10, 3 );
// put this line inside a function,
// presumably in response to something the user does
// otherwise it will schedule a new event on every page visit
wp_schedule_single_event( time()+3600, 'my_new_event', array( $arg1, $arg2, $arg3 ) );
// time()+3600 = one hour from now.
Since: 2.1.0
wp_schedule_single_event() is located in wp-includes/cron.php
For a comprehensive list of functions, take a look at the category Functions
Other Cron functions can be found on the WP-Cron functions page