Cron Job not working in plugin

The cron event needs to be registered on the plugin activation hook like so:

register_activation_hook( __FILE__, 'activate_cron' );
function activate_cron() {
    wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'the_function_to_run' );
}

The the_function_to_run defined in the wp_schedule_event needs to be your function that you want to run at the time interval.

Note: When you say something is “Not Working” it is really hard to answer. Please be more specific to get better answers.

Leave a Comment