-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syncing first/last name fields on an existing user without a fullName mapping will not update fullName #32
Comments
I suppose this is true for anything when The reason we use a stepped process in All too happy to add an event here to help. |
Hey thanks for the swift response! I think you're likely right, if I agree it would suck to lose the current benefits An event would definitely help my use-case, though my current workaround works well enough that I'm not desperate for it. |
Describe the bug
When syncing an existing user profile, if
fullName
is set and there's no mapping set on the provider (which is the case for Google, and likely others), it can fall out of sync with thefirstName
andlastName
fields.Craft handles this on
User::afterSave
viaNameTrait::prepareNamesForSave()
, but As of 4.9 only iffullName
or first/last name is null.(Sorry in advance if this should be a feature request; its hard to tell what the expected behaviour should be)
Steps to reproduce
populateProfile
andsyncProfile
totrue
in social settingsfName lName
(assuming SSO first/last name isn't the same)fieldMapping
forfirstName
andlastName
but notfullName
(eg; Google provider)Craft CMS version
4.9.5
Plugin version
1.0.15
Multi-site?
No
Additional context
To fix, could use
User::setAttributes()
instead of manually assigning values onto the user object inservices\Users::_syncUserProfile()
. The function handlesfirstName
/lastName
logic (see: https://github.com/craftcms/cms/blob/5.x/src/elements/User.php#L995-L1006).Alternatively, adding an event onto
_syncUserProfile
where I could manually setfullName = null
would be handy, as right now I'm resolving by emulating the setAttributes conditional onUser::EVENT_BEFORE_SAVE
The text was updated successfully, but these errors were encountered: