diff --git a/CHANGELOG.md b/CHANGELOG.md index e8dba40cfd6..30e5b3c4243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Slideout sidebars are now always toggleable; not just when the slideout is too narrow to show the sidebar alongside the content. ([#14418](https://github.com/craftcms/cms/pull/14418)) - Field Layout Designers now hide the component library sidebar in favor of “Add” disclosure menus, when they’re too narrow to show the sidebar alongside configured tabs. ([#14411](https://github.com/craftcms/cms/pull/14411)) +- Fixed a bug where it wasn’t possible to clear out users’ full names once they were set. ([#14402](https://github.com/craftcms/cms/pull/14402)) ## 5.0.0-beta.2 - 2024-02-15 diff --git a/src/elements/User.php b/src/elements/User.php index 4cbe0c1d1fe..dc51beee694 100644 --- a/src/elements/User.php +++ b/src/elements/User.php @@ -973,7 +973,14 @@ public function setAttributes($values, $safeOnly = true): void } } - if (array_key_exists('firstName', $values) || array_key_exists('lastName', $values)) { + if (array_key_exists('fullName', $values)) { + // Clear out the first and last names. + // They'll get reset from prepareNamesForSave() if fullName isn't empty. + $this->firstName = null; + $this->lastName = null; + } elseif (array_key_exists('firstName', $values) || array_key_exists('lastName', $values)) { + // Clear out the full name. + // It'll get reset from prepareNamesForSave() if the first/last names aren't empty. $this->fullName = null; }