כמעט ואין תיעוד בנושא זה, ולקובץ ה-API של התוסף אין הערה המסבירה את השימוש בפונקציה זו. בנוסף, המקום היחיד שבו אני יכול לראות אותה בשימוש הוא בתוספים, לא בליבה. אז מה בדיוק עושה api.addSaveableUserOptionField()? האם נדרשת תצורה נוספת לשימוש בה?
סיכום מבוסס בינה מלאכותית
NateDhaliwal inquired about the undocumented function api.addSaveableUserOptionField(), noting its absence in core code and lack of comments. pfaffman explained that this is a specific hook designed for plugins to define their own user options, citing its usage in the Chat plugin as an example. NateDhaliwal confirmed their intent to create a plugin with user settings and sought a documented method, having previously observed its use in the Chat and AI plugins. Later, NateDhaliwal discovered additional related functions in the plugin API source code: addSaveableUserField(), addSaveableUserOption(), and addSaveableCustomFields(). They questioned whether the latter two require backend registration via register_custom_user_field or if they function within a Topic Controller. pfaffman suggested that these functions likely support both UX-defined custom fields (often named user_field_1) and plugin-defined fields, recommending experimentation with both naming conventions to determine the correct implementation.
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.
כן, אני מתכנן שיהיה לי הגדרת משתמש בתוסף. ראיתי בעבר ש-Chat ו-IIRC AI השתמשו בפונקציה זו כדי להוסיף הגדרות משתמש, אז תהיתי אם יש דרך מתועדת לעשות זאת.
Coming back to this, there seems to be more info on this.
This now lists 3 functions: addSaveableUserField(), addSaveableUserOption(), and addSaveableCustomFields().
It seems like the 1st refers to adding and saving admin-defined custom user fields. However, the next 2 aren’t so clear. Do they require a plugin to use register_custom_user_field :... in the backend? Does more need to be done, or can it work in a TC?
Thanks.
It looks like it works for both custom fields added in the UX and via a plugin. For custom fields, they get names like user_field_1, I’m pretty sure. You can look in the table with data explorer, for example. Or maybe it means only fields added by the UX (“admin-defined profile fields”), in which case you’d use the name you gave it when you created it. I’d just try it both ways.
And github is down, so I can’t look at the code there.