Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created April 19, 2021 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/d301423a20c85e93f0f36c2c4b3435cd to your computer and use it in GitHub Desktop.
Save Pebblo/d301423a20c85e93f0f36c2c4b3435cd to your computer and use it in GitHub Desktop.
Example of how you can remove all EE3 events (and related data INCLUDING attendees) from your database. Uncomment line 16 to actually delete anything using this function.
<?php
global $wpdb;
$last_year = date('Y-m-d', strtotime( current_time('Y-m-d') . ' -1 year' ));
echo $last_year;
$sql = 'SELECT e.id event_id, e.end_date';
$sql .= ' FROM '. EVENTS_DETAIL_TABLE . ' e ';
$sql .= ' WHERE e.end_date < "' . $last_year . '"';
$sql .= ' ORDER BY e.id DESC LIMIT 200';
$events = $wpdb->get_results( $sql );
foreach( $events as $event ) {
//event_espresso_empty_event_trash($event->event_id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment