# Trouble searching user custom fields

**URL:** https://meta.discourse.org/t/trouble-searching-user-custom-fields/404800
**Category:** Bug
**Created:** [June 8, 2026, 10:34pm UTC](https://meta.discourse.org/t/trouble-searching-user-custom-fields/404800 "2026-06-08T22:34:35Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [June 9, 2026, 8:46pm UTC](https://meta.discourse.org/t/trouble-searching-user-custom-fields/404800/3 "2026-06-09T20:46:38Z")

</div>

> [@pfaffman](#):
>
> I’m pretty sure that this used to work and that this is a regression.

I couldn’t find _when_ it used to work but I was able to fix (or rather make consistent) both code paths

> <https://github.com/discourse/discourse/pull/40698>
>
> 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

---

_[View the full topic](https://meta.discourse.org/t/trouble-searching-user-custom-fields/404800)._
