diff --git a/services/OneCampaignMonitor_SubscribersService.php b/services/OneCampaignMonitor_SubscribersService.php index cdd71c8..0478fe6 100644 --- a/services/OneCampaignMonitor_SubscribersService.php +++ b/services/OneCampaignMonitor_SubscribersService.php @@ -102,32 +102,14 @@ public function update($listId, $email, $name=null, $customFields=array(), $resu $existingSubscriber = $result->response; - // Count the number of occurances of custom field to know - // which is a Multi-Valued Select Many field - $fieldOccurances = []; foreach ($existingSubscriber->CustomFields as $existingField) { - if (array_key_exists($existingField->Key, $fieldOccurances)) { - $fieldOccurances[$existingField->Key]++; - } else { - $fieldOccurances[$existingField->Key] = 1; - } + $subscriber['CustomFields'][] = [ + 'Key' => $existingField->Key, + 'Value' => $existingField->Value + ]; } - - // For any Multi-Valued Select Many field, make sure to append the - // existing field values - foreach($fieldOccurances as $key => $value) { - if ($value > 1) { - foreach($existingSubscriber->CustomFields as $existingField) { - if ($existingField->Key == $key) { - $subscriber['CustomFields'][] = $existingField; - } - } - } - } - } else { - $subscriber['CustomFields'] = $parsedCustomFields; } - + $result = $connection->update($email, $subscriber); $error = null;