# 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:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [June 8, 2026, 10:34pm UTC](https://meta.discourse.org/t/trouble-searching-user-custom-fields/404800/1 "2026-06-08T22:34:36Z")

</div>

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.

---

<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

---

<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 15, 2026, 10:21am UTC](https://meta.discourse.org/t/trouble-searching-user-custom-fields/404800/4 "2026-06-15T10:21:23Z")

</div>


