pmpro_maybe_schedule_event

Schedule a periodic event unless one with the same hook is already scheduled.

Description

(false|void) pmpro_maybe_schedule_event( (int) $timestamp, (string) $recurrence, (string) $hook, (array) $args = array() ); 

Returns (false|void)

False when an event is not scheduled.

Parameters (4)

0. $timestamp (int)
Timestamp for when to run the event.
1. $recurrence (string)
How often the event should recur.
2. $hook (string)
Action hook to execute when cron is run.
3. $args — Optional. (array) => array()
Arguments to pass to the hook's callback function.

Usage

  1. if ( !function_exists( 'pmpro_maybe_schedule_event' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // Timestamp for when to run the event. 
  5. $timestamp = -1; 
  6.  
  7. // How often the event should recur. 
  8. $recurrence = ''; 
  9.  
  10. // Action hook to execute when cron is run. 
  11. $hook = ''; 
  12.  
  13. // Optional. Arguments to pass to the hook's callback function. 
  14. $args = array(); 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = pmpro_maybe_schedule_event($timestamp, $recurrence, $hook, $args); 
  18.  

Defined (1)

The function is defined in the following location(s).

/includes/functions.php  
  1. function pmpro_maybe_schedule_event( $timestamp, $recurrence, $hook, $args = array()) { 
  2. $next = wp_next_scheduled($hook, $args); 
  3. if(empty($next)) 
  4. return wp_schedule_event($timestamp, $recurrence, $hook, $args); 
  5. else 
  6. return false;