# 按自定义字段排序时用户目录搜索中断

**URL:** https://meta.discourse.org/t/user-directory-searching-broken-when-sorted-by-custom-field/217887
**Category:** Bug
**Created:** [2022年二月11日 15:11 UTC](https://meta.discourse.org/t/user-directory-searching-broken-when-sorted-by-custom-field/217887 "2022-02-11T15:11:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gale](https://avatars.discourse-cdn.com/v4/letter/g/a9a28c/32.png) [@gale](https://meta.discourse.org/u/gale)
#### Post date: [2022年二月11日 15:11 UTC](https://meta.discourse.org/t/user-directory-searching-broken-when-sorted-by-custom-field/217887/1 "2022-02-11T15:11:14Z")

</div>

当排序列是自定义用户字段时，用户目录搜索选项（自由文本和组选择）不起作用。搜索显然会运行，但返回的结果仍然包含所有用户，无论搜索什么或选择哪个组。如果我选择一个标准字段（用户名、帖子、回复等），搜索功能就会再次按预期工作。

在我的用例中，我的目录中有两个自定义用户字段，它们都是文本字段类型，并且都可以搜索。运行版本 2.9.0.beta1。

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2022年二月15日 08:10 UTC](https://meta.discourse.org/t/user-directory-searching-broken-when-sorted-by-custom-field/217887/4 "2022-02-15T08:10:40Z")

</div>

> <https://github.com/discourse/discourse/pull/15951>
>
> Since the "users" table is already added in the "\`includes\`" method it gives une…xpected results while using it again in the "\`joins\`" method.

此 PR 将修复此问题。
