Add/remove CRON action depending on variable

I am not sure why the remove_action isn’t working because by the looks of your code, it should. Alternatively, you can add the conditional logic to your generate_sitemap() function generate_sitemap() { global $create_sitemap; if ( $create_sitemap ) return false; $sitemap = ‘<?xml version=”1.0″ encoding=”UTF-8″?>’; $sitemap .= ‘<urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9″>’; // Get a query of all jobs … Read more

WordPress cronjob get scheduled but function does not run

I believe you need to use wp_get_current_user() (see https://codex.wordpress.org/Function_Reference/wp_get_current_user ), which will return the current WP user information as an object. From there, you can get the user name (or other parameters). From that page, this example should get you started: $current_user = wp_get_current_user(); /** * @example Safe usage: $current_user = wp_get_current_user(); * if ( … Read more

WordPress Cron job, 302 response

The problem here is a mistake regarding how to schedule a cron event, lets begin with: wp_schedule_event(time(), ‘hourly’, ‘my_schedule_hook’, $args); wp_schedule_event(time(), ‘hourly’, ‘update_user_hours’); Here you are telling WordPress to fire the update_user_hours action/event on an hourly basis. You then hook into this to fire a callback: add_action(‘update_user_hours’, ‘do_this_hourly’); But then, instead of declaring do_this_hourly, for … Read more

Media Library Latency, Lag, CRON?

When I add images to my Media Library they aren’t available in the Media Library for about an hour. It seems like there is a queue or some sort of CRON that fires. WordPress handles uploads immediately, there is no latency, queues, or cron unless you introduce one yourself. The image appears in the media … Read more

Scheduling WP cron jobs

you could use something like this, WP Crontrol to see what those events might be and when they are scheduled to run ( interval ), but the time of the day ( when they run ) is controlled by visitors viewing your site ( which is why they run during the day, because that when … Read more