Bug Description
When editing a user in the admin UI, custom profile fields defined via defineUserProfile() are not persisted unless at least one standard profile field (display name, bio, company, job title, website, location, or date of birth) also has a value.
Steps to Reproduce
- Define a custom user profile field:
defineUserProfile({
fields: [
{ name: 'plan', label: 'Plan', type: 'radio', options: ['free', 'monthly', 'annual', 'lifetime'], default: 'free', required: true }
]
})
- Go to Admin → Users → Edit a user
- Change the "Plan" radio button to a new value (e.g. "monthly")
- Leave all standard profile fields (display name, bio, company, etc.) empty
- Click Save
- Reload the page — the plan field reverts to the old value
Root Cause
In the admin user PUT handler (userRoutes.put("/users/:id", ...)), the profile save logic is gated on standard fields:
const hasProfileData = profileDisplayName || profileBio || profileCompany || profileJobTitle || profileWebsite || profileLocation || profileDateOfBirth;
if (hasProfileData) {
// ... UPDATE or INSERT user_profiles including customDataJson ...
}
If all standard profile fields are empty/null, the entire block is skipped — customDataJson is computed but never written to the database.
Fix
The condition should also check for custom data:
if (hasProfileData || customDataJson !== null) {
This ensures custom profile fields are saved even when no standard profile fields are filled in.
Environment
@sonicjs-cms/core: 2.12.1
Bug Description
When editing a user in the admin UI, custom profile fields defined via
defineUserProfile()are not persisted unless at least one standard profile field (display name, bio, company, job title, website, location, or date of birth) also has a value.Steps to Reproduce
Root Cause
In the admin user PUT handler (
userRoutes.put("/users/:id", ...)), the profile save logic is gated on standard fields:If all standard profile fields are empty/null, the entire block is skipped —
customDataJsonis computed but never written to the database.Fix
The condition should also check for custom data:
This ensures custom profile fields are saved even when no standard profile fields are filled in.
Environment
@sonicjs-cms/core: 2.12.1