Posting custom user fields via the Ember side User model just ignores the fields

Continuing the discussion from Adding Custom Fields via Plugin Outlet:

I just tried to add a custom setting to user-preferences-profile outlet.

I also reopened the controllers/preferences/profile.js to add my attribute to saveAttrNames array in order for my custom attributes to be passed to the save method of the ember side user model. But with some debugging, I found out that the user model’s save method simply drops the field if it isn’t already named in userFields, userOptionFields or so with one of those _.intersection calls.

I’m proposing an API to be able to send that data to the server via the user model itself or if its an intentional design choice, I am looking to understand the rationale behind it or whether there’s a different way to achieve this.

My use case is adding a setting to the preferences pages via a plugin and saving them with the other preferences using the same Save Changes button.

I’m aware of the fact that discourse-cakeday does so but the date_of_birth field is present in the userFields array which makes it work.

1 Like