WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp schedule single event

Description

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.

Usage

 <?php wp_schedule_single_event(time(), 'my_schedule_hook'); ?> 

Examples

Schedule an event one hour from now

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.

Parameters

$timestamp
(integer) (required) The time you want the event to occur. This must be in a UNIX timestamp format.
Default: None
$hook
(string) (required) The name of an action hook to execute.
Default: None
$args
(array) (optional) Arguments to pass to the hook function(s)
Default: None