Sorting custom user field dropdown items

סיכום מבוסס בינה מלאכותית

jenmck asks for an easier way to sort dropdown options for custom user fields, as new items currently appear at the bottom of long, alphabetized lists, requiring tedious manual reordering via arrow clicks. They inquire about potential solutions such as a native “display alphabetically” option, a theme component workaround, or the feasibility of an API endpoint for this task. They also question whether existing user selections would be preserved if the entire dropdown list were replaced via a cron job.

chapoi points out that this is a known feature request discussed in a previous topic and recommends voting on that thread to help prioritize the work, rather than starting a new discussion.

pacharanero suggests a programmatic workaround using the dsc (Discourse Site Control) CLI tool. This method allows users to pull the custom user field data locally, sort the options within the YAML configuration, and push the updated configuration back to the server. They note that local AI agents can effectively assist with this sorting process via the CLI.

I have a custom user field with a very long list of dropdown options. For reasons, users are not allowed to enter their own value in this field, and this field must exist as a dropdown, and it is a required field for all users.

From time to time, I need to add or remove items to the list. Because it’s such a long list, I have it alphabetized.

The pain here is that new items are added to the bottom, and i need to manually click the up arrow for each new item in order to re-alphabetize the list.

I did a search, and got this AI result, which is incorrect - there is no Admin > Customize > User Fields page.

I checked for an API endpoint at docs.discourse.org and didn’t see anything related to custom user fields.

This topic: Dynamically update available user field values during a profile fill in does outline a method for updating the list using a cron job (though it’s not quite my use case, it is similar enough). I’m very leery of doing it this way, though.

I have searched for other topics related to this; I know I had asked about it about 3 years ago, but didn’t want to necro that topic.

My questions:

  • is there an easier way to sort dropdown lists than clicking the arrow manually for each item
  • would it seem like something feasible to add a display alphabetically option or have it manually display alphabetically using a theme component, or is this more complicated to accomplish than it seems?
  • if the only option is to go the route of creating a cron job for it, if the dropdown list is completely replaced, would current users retain the selection they’ve already made, if it is listed exactly the same in the replaced list?
  • what would be the chances that this could be added as an API endpoint?

Sincerely,
someone with a lot of clicking to do

There isn’t any new information so I’d recommend to add your vote to that one (it has zero votes atm and the voting feature is often how we prioritze work). It’s totally fine to bring it back alive! And often better to keep all asks grouped instead of scattered across multiple support topics.

You could use dsc to pull the UCF data locally, then sort the range of lines in YAML and push back up.

Any local AI agent will be able to do this for you very well using the CLI tool