From f7c13dd8dd17f56d78bd6003e38fd009822646c7 Mon Sep 17 00:00:00 2001 From: UVLabs Date: Thu, 6 Jul 2023 14:00:53 -0400 Subject: [PATCH] fix: Error when contact not found in mautic --- includes/Contacts/Update.php | 3 +++ index.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/Contacts/Update.php b/includes/Contacts/Update.php index 7142012..9c73d4f 100644 --- a/includes/Contacts/Update.php +++ b/includes/Contacts/Update.php @@ -57,6 +57,9 @@ public function updateContactTags(array $add_tags = array(), array $remove_tags { $email = $this->user_data['email']; $contact_details = $this->findContactDetailsByEmail($email); + if (empty($contact_details)) { + return 0; + } $contact_id = $contact_details['id']; $contact_current_tags = array_column($contact_details['tags'], 'tag'); diff --git a/index.php b/index.php index 4833f95..4406fa0 100644 --- a/index.php +++ b/index.php @@ -13,7 +13,7 @@ * @link https://uriahsvictor.com * @since 1.0.1 * @license GPLv2 - * @version 1.1.2 + * @version 1.1.3 */ use CoachFreem\Contacts\Create as CreateContact; @@ -89,6 +89,7 @@ function init(ServerRequestInterface $request): string $custom_mappings = customContactDataMappings(); $segments = contactSegments(); $tags = contactTags(); + $contactCreate->setCustomMappings($custom_mappings) ->setSegments($segments) ->setTags($tags)