Skip to content

Instantly share code, notes, and snippets.

@slimndap
Last active January 4, 2023 22:57
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 slimndap/6d9fe9db9d83d8ef994e1c6bd6fc8fe0 to your computer and use it in GitHub Desktop.
Save slimndap/6d9fe9db9d83d8ef994e1c6bd6fc8fe0 to your computer and use it in GitHub Desktop.
A Jeero extension plugin that prevents Jeero from importing events from the Stager ticketing system to The Events Calendar, if an event has a publication date in the future. The plugin is written by ChatGPT!
<?php
/*
Plugin Name: Jeero Event Date Check
Description: Prevents Jeero from importing events with a future publication date.
Version: 1.0
Author: Your Name
*/
function jeero_stop_future_events( $result, $data, $raw, $theater, $subscription ) {
// Check if $result is already a WP_Error object
if ( is_wp_error( $result ) ) {
// If $result is a WP_Error, return it without checking the event publication date
return $result;
}
// Get the event publication date from the $raw array and convert it to a timestamp
$event_date = strtotime( $raw['publicationDate'] );
// Get the current time in the site's timezone
$current_time = current_time( 'timestamp' );
// Check if the event date is in the future
if ( $event_date > $current_time ) {
// Return a new WP_Error object to stop the event from being imported
return new WP_Error( 'event_in_future', 'Event publication date is in the future' );
}
// If the event date is not in the future, return the original result
return $result;
}
add_filter( 'jeero/inbox/process/item/import/calendar=The_Events_Calendar', 'jeero_stop_future_events', 9, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment