1
方法在一定的時間間隔來執行自定義事件WordPress的定時任務不執行
function informant_main_action(){
die('working');
}
自定義計劃的計劃作業
function my_cron_definer($schedules){
$schedules['weekly'] = array('interval'=> 120, //604800
'display'=> __('Once Every week')
);
return $schedules;
}
add_filter('cron_schedules','my_cron_definer');
註冊日程上的插件激活
register_activation_hook(__FILE__, 'informant_run_on_activation');
function informant_run_on_activation(){
if(!wp_next_scheduled('informantweeklynewsletter')){
wp_schedule_event(time(), 'weekly', 'informantweeklynewsletter');
}
}
打電話給我在自定義事件上執行的方法
add_action('informantweeklynewsletter','informant_main_action');
我已經安裝了一個插件Cron Gui來查看預定的cronjob,並且它正在列出我的事件,因爲我把每兩分鐘的重現次數顯示出正確的結果,即更新時間+2分鐘。
但我的方法informant_main_action()
不起作用。什麼是我犯的錯誤。 ?
感謝
嘗試一個郵件功能,而不是死....你永遠不能確定,如果你會成爲一個觸發cron .... – David 2014-09-05 14:47:53