dphj737575 2014-10-02 14:51
浏览 35

如何在执行某些操作后在wordpress中设置单个计划事件

I have a function which sends an email when a task is completed

   function complete_task($id)
   {
      wp_mail('abc@mail.com','test subject', 'test message');
   }

Now I want to change this as when a specific task with the ID is completed then it should not send an email instead of registring a schedule event. I have done this with wp_schedule_single_event

my code for this is below:

   function complete_task($id)
   {
      if($id!=3) // 3 is any ID
       {
            wp_mail('abc@mail.com','test subject', 'test message');
       }
       else
       {
           add_action( 'send_single_email_event', 'do_this_in_after_1_hour', 10, 3 );
       }
   }

I have added the add_action hook in else section because in codex there is written to add this in a function you can check it here Schedule an event one hour from now

   // function for sending schedule event
   function do_this_in_after_1_hour() 
   {
     wp_mail( 'abc@mail.com', 'test subject', 'test message');
   }
   // singdle schedule event
   wp_schedule_single_event(time() + 3600, 'send_single_email_event');

its not working, mean not sending email.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ogg dd trandata 报错
    • ¥15 高缺失率数据如何选择填充方式
    • ¥50 potsgresql15备份问题
    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错