Skip to content

Instantly share code, notes, and snippets.

@LaxusCroco
Created September 28, 2023 13:24
Show Gist options
  • Save LaxusCroco/7fd2a4d10ea52e4abc50f202fd2e9483 to your computer and use it in GitHub Desktop.
Save LaxusCroco/7fd2a4d10ea52e4abc50f202fd2e9483 to your computer and use it in GitHub Desktop.
This will ensure that the old appointments (the time of which has passed) are deleted daily.
<?php
add_action( 'init', function() {
if ( ! function_exists( 'jet_apb' ) ) {
return;
}
if ( ! wp_next_scheduled( 'delete_old_appointments' ) ) {
wp_schedule_event( time(), 'daily', 'delete_old_appointments' );
}
add_action( 'delete_old_appointments', function() {
global $wpdb;
$table = jet_apb()->db->appointments->table();
$wpdb->query( "DELETE FROM $table WHERE slot_end < UNIX_TIMESTAMP();" );
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment