admin管理员组文章数量:1130349
I have tried the following two approaches, each resulting that the cronjob gets added over and over again, until I remove the code. I literally had it scheduled hundreds of times...
if(!wp_next_scheduled('send_order_surveys')){
wp_schedule_event(time(), '30min', 'send_order_surveys');
}
if(!wp_get_schedule('send_order_surveys')){
wp_schedule_event(time(), '30min', 'send_order_surveys');
}
What am I doing wrong?
I have tried the following two approaches, each resulting that the cronjob gets added over and over again, until I remove the code. I literally had it scheduled hundreds of times...
if(!wp_next_scheduled('send_order_surveys')){
wp_schedule_event(time(), '30min', 'send_order_surveys');
}
if(!wp_get_schedule('send_order_surveys')){
wp_schedule_event(time(), '30min', 'send_order_surveys');
}
What am I doing wrong?
Share Improve this question asked Dec 21, 2018 at 14:19 Johano FierraJohano Fierra 8256 silver badges12 bronze badges1 Answer
Reset to default 7Well, I found the answer in the actual documentation: https://developer.wordpress/reference/functions/wp_next_scheduled/
in form of a comment by "ub3rst4r":
Note the $args parameter! Not specifying the $args parameter in wp_next_scheduled but having $args for wp_schedule_event will cause many events to be scheduled (instead of just one).
Bad Example:
if ( ! wp_next_scheduled( 'myevent' ) ) { // This will always be false
wp_schedule_event( time(), 'daily', 'myevent', array( false ) );
}
Good Example:
$args = array( false );
if ( ! wp_next_scheduled( 'myevent', $args ) ) {
wp_schedule_event( time(), 'daily', 'myevent', $args );
}
I have tried the following two approaches, each resulting that the cronjob gets added over and over again, until I remove the code. I literally had it scheduled hundreds of times...
if(!wp_next_scheduled('send_order_surveys')){
wp_schedule_event(time(), '30min', 'send_order_surveys');
}
if(!wp_get_schedule('send_order_surveys')){
wp_schedule_event(time(), '30min', 'send_order_surveys');
}
What am I doing wrong?
I have tried the following two approaches, each resulting that the cronjob gets added over and over again, until I remove the code. I literally had it scheduled hundreds of times...
if(!wp_next_scheduled('send_order_surveys')){
wp_schedule_event(time(), '30min', 'send_order_surveys');
}
if(!wp_get_schedule('send_order_surveys')){
wp_schedule_event(time(), '30min', 'send_order_surveys');
}
What am I doing wrong?
Share Improve this question asked Dec 21, 2018 at 14:19 Johano FierraJohano Fierra 8256 silver badges12 bronze badges1 Answer
Reset to default 7Well, I found the answer in the actual documentation: https://developer.wordpress/reference/functions/wp_next_scheduled/
in form of a comment by "ub3rst4r":
Note the $args parameter! Not specifying the $args parameter in wp_next_scheduled but having $args for wp_schedule_event will cause many events to be scheduled (instead of just one).
Bad Example:
if ( ! wp_next_scheduled( 'myevent' ) ) { // This will always be false
wp_schedule_event( time(), 'daily', 'myevent', array( false ) );
}
Good Example:
$args = array( false );
if ( ! wp_next_scheduled( 'myevent', $args ) ) {
wp_schedule_event( time(), 'daily', 'myevent', $args );
}
本文标签: wpgetschedule and wpnextscheduled don39t find my scheduled wpcron job
版权声明:本文标题:wp_get_schedule and wp_next_scheduled don't find my scheduled wp-cron job 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749077700a2312561.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论