duanjie2940 2015-03-07 08:35
浏览 40

卷曲不在wordpress计划事件/ cron中工作

I created a wordpress schedule event using the following code

add_filter('cron_schedules','cliv_cron_add_syncdays');
function cliv_cron_add_syncdays($schedules){
   $schedules['syncdays'] = array(
       'interval' => 15,
       'display'=> 'Sync Days'
   );
   return $schedules;
}

add_action('init','cliv_create_recurring_schedule');
add_action('cron_action','cron_function');

function cron_function(){

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER,array("DATA SYNC"));
    $result = curl_exec($ch);
    curl_close($ch);
    $response = json_decode($result, true);

    mail("mymail@mail.com", "wp Cron test", $response);

}

function cliv_create_recurring_schedule(){
  if(!wp_next_scheduled('cron_action'))
   wp_schedule_event (time(), 'syncdays', 'cron_action');
}

if i call the cron_function() directly, everything works. But if the function is run from cron, mail is received but without the data. ( i guess curl not working in this case).

Guys. can you help me out here please.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突