Mohammed
Mohammed

Reputation: 31

How to add Cron to WordPress

I trying to develop a plugin to send emails to users in a specific time, so I have created my plugin like that :

add_action( 'my_hourly_event',  'sendEmail' );
public static function activate() {
    wp_schedule_event( time(), 'hourly', 'my_hourly_event' );
} // end activate

public static function deactivate() {
    wp_clear_scheduled_hook('my_hourly_event');
} // end activate

function sendEmail() { 
    wp_mail( $email, $subject, $message );
}

Then I add this to wp-config.php :

define('DISABLE_WP_CRON', true);

Finally I add my cron in my site :

* /15 * * * wget -q -O - http://yourdomain.com/wp-cron.php?doing_wp_cron

But I didn't get anything, so please if someone has any idea I will be very appreciative.

Upvotes: 1

Views: 70

Answers (1)

Raphaël Vigée
Raphaël Vigée

Reputation: 2045

If you add :

define('DISABLE_WP_CRON', true)

To wp-config.php, it's normal that your CRON is not gonna be executed; try removing this line or replacing it by :

define('DISABLE_WP_CRON', false)

Upvotes: 2

Related Questions