'i need to make custom cron_schedule with custom interval time as a parameter into a custom payment gateway plugin wordpress
i used the defoalt from the documentation to create a custom cron intervals in a custom plugin payment gateway:
i added in the construct the line:
add_filter( 'cron_schedules', array( $this, 'add_cron_interval' ) );
and in the class body the method:
/**
* Adds custom time intervals for the cron.
*/
private function add_cron_interval( $schedules ) {
$options = get_option( 'inquiretimes' );
$interval = ( ! empty( $options ) ? absint( $options ) * HOUR_IN_SECONDS : DAY_IN_SECONDS );
$schedules['wpdocs_interval'] = array(
'interval' => $interval,
'display' => esc_html__( 'Custom Interval' )
);
return $schedules;
}
but when i view the cron schedules it doesn't registered yet! what's wrong as well as when i create schedule with the custom interval i created occurs an error!
public function registerCronJob() {
if ( ! wp_next_scheduled( 'cronPerMinutes' ) ) {
wp_schedule_event( time(), 'wpdocs_interval', 'cronPerMinutes' );
}
}
note that i added the below line in the constructor too:
register_activation_hook(__FILE__,array($this,'registerCronJob'));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
