From: Steve Sutton Date: Mon, 24 Apr 2017 19:22:16 +0000 (-0400) Subject: Only add the event category if it finds the correct id X-Git-Tag: v1.6.37^2~8 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=150da1ebff778b941a7c1877a6bfd6caf138d285;p=WP-Plugins%2Fglm-member-db-events.git Only add the event category if it finds the correct id If it returns false then don't insert a record for it. --- diff --git a/models/front/events/icalFeedImport.php b/models/front/events/icalFeedImport.php index eaa1390..532b430 100644 --- a/models/front/events/icalFeedImport.php +++ b/models/front/events/icalFeedImport.php @@ -271,14 +271,17 @@ class GlmMembersFront_events_icalFeedImport if ( isset( $event['CATEGORIES'] ) ) { $category_data = explode( ',', $event['CATEGORIES'] ); foreach ( $category_data as $category ) { - $this->wpdb->insert( - GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'event_categories', - array( - 'event' => $event_id, - 'category' => $this->getCategoryId( $category ) - ), - '%d' - ); + $categoryId = $this->getCategoryId( $category ); + if ( $categoryId ) { + $this->wpdb->insert( + GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'event_categories', + array( + 'event' => $event_id, + 'category' => $categoryId + ), + '%d' + ); + } } } // Location Data