Skip to content

Commit

Permalink
Sync fullName field from users to contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Feb 8, 2024
1 parent 98e6111 commit 36a80c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Release Notes for Campaign

## 2.12.1 - Unreleased
## 2.12.1 - 2024-01-08

### Changed

- The `fullName` field is now synced from users to contacts, provided it exists on the contact field layout ([#452](https://github.com/putyourlightson/craft-campaign/issues/452)).

### Fixed

Expand Down
5 changes: 4 additions & 1 deletion src/services/SyncService.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ public function syncUserMailingList(User $user, MailingListElement $mailingList)
$contact->userId = $user->id;
$contact->email = $user->email;

// Set first and last name from user fields only if they exist
// Set the name fields from user fields only if they exist
if (isset($contact->fullName)) {
$contact->setFieldValue('fullName', $user->fullName);
}
if (isset($contact->firstName)) {
$contact->setFieldValue('firstName', $user->firstName);
}
Expand Down

0 comments on commit 36a80c3

Please sign in to comment.