Connecting custom user fields to plugins/theme components

I was wondering if there’s currently a way (or if not, how one could create a way) to allow plugins and theme components to easily access custom user fields.

First, I installed the Discourse Chatbot 🤖 (supporting ChatGPT) - #239 by matenauta and wanted the system prompt setting of the plugin to easily access custom user fields so each user could customize the prompt, ideally the custom user fields showing up as interpolation keys so they can be added to customized text (Create and configure custom user fields - #55 by jimkleiber)

Then I recently installed Discourse Tab Bar for Mobile and I was thinking that users may want to customize the different button options. As far as I know, right now only the admin can customize the plugin settings that control which buttons appear in which order.

I imagine this could be useful for a lot of other plugins and components, as it could allow users to customize the plugins/components from their own profile.

I’m not sure if this is currently possible as an end-user, would require each plugin author to add custom code, or could be through a custom plugin/component that could add this functionality to all plugins/components on the site.

Does anyone have any idea about how I’d best go about achieving this?

2 Likes

A hint, but not a proper answer, is that you want to add those custom fields to the serializer in a plugin.

I thought that user custom fields were in the serializer if they were on the user card or profile, but they don’t seem to be, so, if you don’t get a better answer, you’d need to look for a plugin that modifies the user serializer for an example.

4 Likes

Ah OK, I’ll take a look at that, thank you :pray:

Any idea why user custom fields aren’t added to the serializer?

2 Likes

ok i am interested in this idea. i have a custom user field i created for my users and i’d like to access the setting at some point in the future. i will keep an eye on this topic.

3 Likes