简体   繁体   English

wp cron wordpress问题

[英]wp cron wordpress issue

In my wordpress website, I want to send a reminder every 30 days to the users that have not completed their profiles. 我想在我的wordpress网站上每30天向尚未完成个人资料的用户发送提醒。 I started with making a simple example to test the cron, but it is not working. 我从制作一个简单的示例来测试cron开始,但是它不起作用。 Can you please help me fix it? 你能帮我解决吗? The SendEmailRemiderToESN function is not working. SendEmailRemiderToESN函数不起作用。

// send reminder
    // Scheduled Action Hook
    function SendEmailRemiderToESN( ) {
        wp_mail( "sammoudi.maher@gmail.com","TestCron","Hello" );
    }
    add_action( 'SendEmailRemiderToESN', 'SendEmailRemiderToESN' );

    // Custom Cron Recurrences
    function custom_cron_job_recurrence( $schedules ) {
        $schedules['every30days'] = array(
            'display' => __( 'every30days', 'textdomain' ),
            'interval' => 2592000,
        );
        return $schedules;
    }
    add_filter( 'cron_schedules', 'custom_cron_job_recurrence' );

    // Schedule Cron Job Event
    function custom_cron_job() {
        if ( ! wp_next_scheduled( 'SendEmailRemiderToESN' ) ) {
            wp_schedule_event( current_time( 'timestamp' ), 'every30days', 'SendEmailRemiderToESN' );
        }
    }
    add_action( 'wp', 'custom_cron_job' );

Test this ;) it's working in localhost on my mac 测试这个;)它在我的Mac上的localhost中工作

function custom_cron_job_recurrence_own( $schedules ) {

    $schedules['every30days'] = array(
        'interval'  => 2592000,
        'display'   => __( 'every30days', 'textdomain' )
    );

    return $schedules;
}
add_filter( 'cron_schedules', 'custom_cron_job_recurrence_own' );


if ( ! wp_next_scheduled( 'SendEmailRemiderToESN' ) ) {
    wp_schedule_event( time(), 'every30days', 'SendEmailRemiderToESN' );
}
add_action('SendEmailRemiderToESN', 'custom_cron_job_recurrence');

function custom_cron_job_recurrence() {

    wp_mail(................);

};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM