Clear the event categories first.
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 24 Apr 2017 19:07:17 +0000 (15:07 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 24 Apr 2017 19:07:17 +0000 (15:07 -0400)
before adding more of the same category to an event.

models/front/events/icalFeedImport.php

index f386bc6..eaa1390 100644 (file)
@@ -261,6 +261,12 @@ class GlmMembersFront_events_icalFeedImport
                 $event_abstract = new GlmDataEvents( $this->wpdb, $this->config );
                 $event_abstract->updateSlug( $event_id );
 
+                // Remove any old category data for this event_id.
+                $this->wpdb->delete(
+                    GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'event_categories',
+                    array( 'event' => $event_id ),
+                    '%d'
+                );
                 // Categories
                 if ( isset( $event['CATEGORIES'] ) ) {
                     $category_data = explode( ',', $event['CATEGORIES'] );