Created
September 28, 2023 13:24
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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