Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active December 27, 2017 19:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joshfeck/19cf49a2a30e939cca6d0a7014f7c183 to your computer and use it in GitHub Desktop.
Add an additional reset to the wp_cron schedule. This is a WordPress plugin.
<?php
/*
Plugin Name: Additional cron event to reset reservation counts
Plugin URI: https://eventespresso.com/
Description: This plugin adds an additional reset to the wp_cron schedule. Runs every hour.
Version: 1.0
Author: Event Espresso
Author URI: https://eventespresso.com/
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
register_activation_hook(__FILE__, 'ee_rsrvd_activation');
function ee_rsrvd_activation() {
if (! wp_next_scheduled ( 'ee_rsrvd_hourly_event' )) {
wp_schedule_event(time(), 'hourly', 'ee_rsrvd_hourly_event');
}
}
add_action('ee_rsrvd_hourly_event', 'reset_rsrvd_counts_hourly');
function reset_rsrvd_counts_hourly() {
\EED_Ticket_Sales_Monitor::reset_reservation_counts();
}

Usage notes

  1. Download the code and upload to your site's wp-content/plugins folder, or copy and paste the above code (minus the plugin header) to a custom functions plugin
  2. Activate the plugin
  3. A wp_cron event will be scheduled to do an hourly reset of the reservation counts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment