Archiving past events imported via iCal feed

WordPress Event Management, Calendars & Registration Forums iCal Extension Archiving past events imported via iCal feed

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 10 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #13515

    The iCal feed I use to import many of our site’s events does not include past events. When an event has passed, the iCal feed no longer includes this event, and the event is automatically moved to the trash of our WP admin. I can restore an event temporarily, but it gets “re-trashed” when the iCal feed syncs.

    I would like our site to include a list of past events, including those imported from this iCal feed. Is there an easy way to “archive” past events imported via iCal without manually recreating an event? Or is there some other way to “disassociate” imported iCal events from the feed imported them?

    Ben Coonley
    #13546

    In theory yes, event’s in feed with ID X will have a post meta key _eventorganiser_feed with value X. Unfortunately at this point there is no appropriate hook to remove that meta key (and so dissociate the event from the feed) prior to the feed updating.

    I’ll add in a eventorganiser_fetch_feed hook and eventorganiser_fetched_feed hook (the former of which could be used to remove ‘old’ events prior to the feed being synced in).

    In the mean time, the following may work

     function my_disassociate_old_events(){
         $feeds = eo_get_feeds( array( 'fields' => 'ids' ) );
         if( $feeds ){
             foreach( $feeds as $feed_id ){
                  $old_events = eo_get_events( array(
                       'numberposts' => -1,
                       'fields' => 'ids',
                       'no_found_rows' => true,
                       'showpastevents' => true,
                       'group_events_by' => 'series',
                       'update_post_term_cache' => false,
                       'update_meta_term_cache' => false,
                       'eo_interval'  => 'expired',
                       'meta_query' => array( array(
                             'key' => '_eventorganiser_feed',
                             'value' => $feed_id,
                       ) )
                  ));
    
                  if( $old_events ){
                       foreach( $old_events as $event_id ){
                            delete_post_meta( $event_id, '_eventorganiser_feed' );
                       }
                  }
            }
         }
      }
      add_action( 'eventorganiser_ical_feed_sync', 'my_disassociate_old_events', 5 );
    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.