Creating and configuring custom user fields

I think you could reorder them with the rails console. I chose to enter the fields with their IDs because it’s more difficult to type a name without typos

ids_in_order = [3, 7, 8, 5, 1, 2]

ids_in_order.each_with_index do |id, index|
  UserField.find(id).update!(position: index)
end
1 лайк

Here is what the “reorder categories” window looks like. I’m guessing if this exists in Discourse there could be a way to use it for user fields too?

1 лайк

I don’t believe so, but I recently wrote a theme component that hides the original display of custom fields on the user card and profile pages and then renders them again, optionally making some HTML-safe (they are adding some info via the API to a custom field that users can’t edit). I think the same idea could be used to add an order field to the custom fields to change the order they are displayed on the card and/or profile.

I think you can use the existing methods for reordering the user fields. It is a little impractical that you have to open the menu again after every position change. This is somewhat annoying when moving across several positions.

But a component that would make the buttons always visible or a checkbox for a “reorder mode” at the top that makes them visible outside the menu could already improve the experience.

1 лайк

Oh. Funny. Yeah. Oops. That’s tons better than my idea. :rofl:

У меня есть пользовательское поле, и я установил для него возможность поиска. Однако на странице пользователей /u единственное поле поиска гласит: «Фильтр по имени пользователя». Когда я ищу содержимое пользовательского поля, результаты не отображаются.

Я вижу значения в списке (я включил этот столбец в настройках). Таким образом, я точно знаю, что эти значения существуют.

Что я делаю не так?

Странно, но значения пользовательского поля являются ссылками, например u?cards=no&name=Female&order=likes_received, и при клике по ним выполняется поиск значения в поле name. При этом ничего не находится.

Вот настройки для этого поля:

Также (не знаю, является ли это подсказкой), когда я сортирую по столбцу этого пользовательского поля, независимо от того, по возрастанию или по убыванию, в верхней части списка всегда оказываются пользователи с пустыми полями (разные пользователи). Только у небольшого числа пользователей есть данные в этом поле, но я ожидал, что все пустые значения будут либо в верхней, либо в нижней части списка, а не в обоих местах одновременно.