Having difficulties with WP cron

You can add debugging statements to your code to verify if the cron job is being scheduled and executed correctly. like you can use error_log() to log messages to the PHP error log: public function schedule_event() { if (!wp_next_scheduled(‘redirection_checker_hook’)) { error_log(‘Scheduling redirection_checker_hook’); wp_schedule_event(time(), ‘every_three_minutes’, ‘redirection_checker_hook’); } } public function redirection_checker_func() { error_log(‘Running redirection_checker_func’); update_option(‘test_option’, ‘success’); … Read more

Generate random number 1-10 upon registration without repeat

All right, I figured it out. But if someone wants to suggest something better, please feel free and I will mark it correct. // array of previously-assigned numbers (get this by looping through the registered users -not shown) $numbers_already_taken = array(3,8,1); // get all the numbers between 1-10 $numbers = range(1, 10); // shuffle the … Read more

Function attached to cron job not running but will run if called manually

It looks like the time() was not set correctly in the first iteration of the function wp_schedule_event; First, remove this task from the queue by adding a function wp_clear_scheduled_hook and reload the page. For your example: wp_clear_scheduled_hook( ‘opportunities_cron_job’ ); Remove the cleaning function. Restart your code. If your date is not set correctly again, use … Read more

Cronjobs at night – but not the rest of the day

To achieve the behavior you’re describing in WordPress, where a cron job runs hourly but only between 2 AM and 5 AM, you have a couple of options. While WordPress doesn’t offer this level of specificity in its default scheduling, you can customize it to suit your needs. Custom Cron Scheduling: This involves creating a … Read more

‘wp_site_health_scheduled_check’ Causes Failure Of Other Scripts

First, turn on WP_DEBUG to get a log of the issue. In your wp-config.php you can add something like: define(‘WP_DEBUG’, true); //record all the errors define(‘WP_DEBUG_LOG’,__DIR__.’/wp-content/.wp-debug.log’); //you may want to move this to a more secure location (outside of the web root) define(‘WP_DEBUG_DISPLAY’, false); //don’t show errors on the front end Second, depending on your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)