wordpress schedule event not firing in set time

独自空忆成欢 提交于 2019-12-05 11:45:57

First of all , 1) You need to setup crontab in your server if you want to work dynamically 2) if you want manually wordpress scheduler will call after the page is run

so,

for the crontab setup below is useful link: crontab

If you want to run your cron in every one hour then you need to add below code:

public function __construct() {
    // Call function for cron
    add_action('init', array( $this, 'send_emails_to_users') );
}

public function send_emails_to_users() {
    if(!wp_next_scheduled('cliv_recurring_cron_job')) {
        // Add "cliv_recurring_cron_job" action so it fire every hour
        wp_schedule_event(time(), 'hourly', 'cliv_recurring_cron_job');
    }
}

add_action('cliv_recurring_cron_job', array( $this, 'send_email') );
public function send_email() {
    //send email code goes here
}

for more information see link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!