Function Reference/wp schedule event

Contents

Description

Schedules a hook which will be executed by the WordPress actions core on a specific interval, specified by you. The action will trigger when someone visits your WordPress site, if the scheduled time has passed. See the Plugin API for a list of hooks.

Usage

<?php wp_schedule_event($timestamp, $recurrence, $hook, $args); ?>

Parameters

$timestamp

(integer) (required) The first time that you want the event to occur. This must be in a UNIX timestamp format. WP cron uses UTC/GMT time, not local time. Use time(), which is always GMT in WordPress. (current_time( 'timestamp' ) is local time in WordPress.)

Default: None

$recurrence

(string) (required) How often the event should reoccur. Valid values are below. You can create custom intervals using the cron_schedules filter in wp_get_schedules().

hourly

twicedaily

daily

Default: None

$hook

(string) (required) The name of an action hook to execute. For some reason there seems to be a problem on some systems where the hook must not contain underscores or uppercase characters.

Notes

The array passed as the $args parameter needs to be an indexed array. Each element in the array is sliced into a separate argument in the do_action_ref_array() call. Despite the name, your array is not passed by reference.

When you add the action that calls your scheduled function, you must specify a priority and the number of elements in the array. Your scheduled function declaration must accept each array element as individual parameters