pfaffman
(Jay Pfaffman)
June 8, 2026, 10:34pm
1
I have several user custom fields that the client wants to be able to search to find users.
If I type a / or use the search at the top of the page, it searches the custom fields and it finds the expected userrs, but searching at /u searches only the username.
The search is calling something like:
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
I’m pretty sure that this used to work and that this is a regression.
3 Likes
I couldn’t find when it used to work but I was able to fix (or rather make consistent) both code paths
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