There’s virtually no documentation on this, and the plugin API file doesn’t have a comment explaining the use of this function. Plus, the only place I can see it used is in plugins, not in core. So what does api.addSaveableUserOptionField() do exactly? Is there additional configuration needed to use it?
I don’t know, but here’s what I think I found out.
But first–My question is why do you care? Is there something you’re trying to do? But maybe if you’re trying to create a plugin that has user options, this is how to to do it. It’s not used in core since it’s a hook especially for plugins to be able to have their own user options.
Looks like it’s used in the Chat plugin like here:
Looks like if your plugin has user options then you use this to establish that it’s a user option with the UserUpdater.
Yes, I’m planning to have a user setting in a plugin. I saw previosuly that Chat and IIRC AI used this function to add user settings, so I was wondering if there was a documentd way of doing it.
Возвращаясь к этому вопросу, похоже, что появилась дополнительная информация.
Теперь здесь перечислены три функции: addSaveableUserField(), addSaveableUserOption() и addSaveableCustomFields().
Похоже, что первая из них относится к добавлению и сохранению пользовательских полей профиля, определённых администратором. Однако две следующие не столь очевидны. Требуется ли для них плагин, чтобы использовать register_custom_user_field :... на стороне бэкенда? Нужно ли сделать что-то ещё, или это может работать в TC?
Спасибо.
Похоже, это работает как для пользовательских полей, добавленных через интерфейс, так и через плагин. Для пользовательских полей, я почти уверен, имена выглядят как user_field_1. Вы можете проверить это в таблице с помощью Data Explorer, например. Или, возможно, речь идет только о полях, добавленных через интерфейс («поля профиля, определенные администратором»), в этом случае вы будете использовать имя, которое вы задали при создании. Я бы просто попробовал оба варианта.
И GitHub сейчас недоступен, поэтому я не могу посмотреть код там.