pfaffman
(Jay Pfaffman)
Juin 8, 2026, 10:34
1
J’ai plusieurs champs personnalisés pour les utilisateurs que le client souhaite pouvoir rechercher pour trouver des utilisateurs.
Si je tape un / ou utilise la recherche en haut de la page, elle recherche dans les champs personnalisés et trouve les utilisateurs attendus, mais la recherche via /u ne recherche que le nom d’utilisateur.
La recherche appelle quelque chose comme :
https://hostname/directory_items?period=all&order=likes_received&name=cutr&cards=yes&user_field_ids=6%7C7%7C8%7C1%7C3&plugin_column_ids=15%7C11
Je suis presque certain que cela fonctionnait auparavant et qu’il s’agit d’une régression.
3 « J'aime »
Je n’ai pas pu déterminer quand cela fonctionnait, mais j’ai pu corriger (ou plutôt rendre cohérentes) les deux voies de code.
main ← directory-search-custom-fields
opened 05:04PM - 09 Jun 26 UTC
Previously, the user directory (`/u`) search only matched usernames -- it never … found people by their *searchable* user custom field values (e.g. "Company" or "Member ID"), even though the quick search did. The gap appeared whenever `enable_names` was off or the term contained `_`, `.` or `-`, so member IDs, emails and phone numbers never matched.
This change lets the directory search those fields too, via an opt-in `search_custom_fields:` option on `UserSearch` that searches the `user_search_data` tsvector (mention autocomplete and chat are unchanged). It also escapes `LIKE` wildcards in the search term with `sanitize_sql_like`, and adds a tooltip warning that the "Searchable" toggle makes a field's value publicly findable in search.
Reported at https://meta.discourse.org/t/trouble-searching-user-custom-fields/404800
1 « J'aime »