schedule_noptin_recurring_background_action()
Schedule an action to run repeatedly with a specified interval in seconds.
Description Description
This is similar to schedule_noptin_background_action()
except that the background task fires repeatedly.
You can pass extra arguments to the hooks, much like you can with do_action()
.
Example usage:
// The action callback function.
function log_name( $name ) {
// Log the name.
log_noptin_message( $name, 'notice' );
}
add_action( 'log_name_every_day', 'log_name', 10, 1 );
// Ask Noptin to fire the hook every x seconds from tomorrow.
schedule_noptin_background_action( DAY_IN_SECONDS, strtotime( '+1 day' ), 'log_name_every_day', 'Brian');
See also See also
Parameters Parameters
- $interval
(int) (Required) (required) How long ( in seconds ) to wait between runs. Default: none.
- $timestamp
(int) (Required) (required) The Unix timestamp representing the date you want the action to run for the first time. Default: none.
- $tag
(string) (Required) (required) Name of the action hook. Default: none.
- $arg
(mixed) (Optional) Additional arguments to pass to callbacks when the hook triggers. Default none.
Return Return
(int|bool) The action id on success. False otherwise.
Source Source
File: includes/functions.php
function schedule_noptin_recurring_background_action() { $args = func_get_args(); $interval = array_shift( $args ); $timestamp = array_shift( $args ); return create_noptin_task( $args )->do_recurring( $timestamp, $interval ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.2.7 | Introduced. |