This is a wp-cron I defined in function.php file, but I don’t get any result in the error log, the event is in the cron list but if I launch it nothing happens.
I have define('WP_DEBUG', true);
And error log enabled on all levels in php.ini
Does anybody know where am I doing wrong?
function cron_daily_whatever() { if (!wp_next_scheduled('check_daily_event')) { wp_schedule_event(time(),'daily','check_daily_event'); } } function my_do_this_daily() { error_log('check'); } add_action('wp','cron_daily_whatever'); add_action('check_daily_event','my_do_this_daily');
SOLUTION I used the snippet
file_put_contents(WP_CONTENT_DIR . '/my-debug.txt', "Response: ".$res."n", FILE_APPEND);
to debug it. And it now works.
Advertisement
Answer
By the default WP_DEBUG log in wp-content, you should define (‘WP_DEBUG_LOG’,TRUE); as well. Then you’ll need to clear your scheduled event(and set it again) to test today if it has already run once. See https://codex.wordpress.org/Function_Reference/wp_clear_scheduled_hook for that.