If it returns false then don't insert a record for it.
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