WordPress.org

Make WordPress Core

Opened 16 months ago

Last modified 25 hours ago

#27304 reopened defect (bug)

Improve user searching

Reported by: johnbillion Owned by: johnbillion
Milestone: 4.3 Priority: normal
Severity: normal Version:
Component: Users Keywords: needs-testing has-patch dev-feedback
Focuses: administration Cc:

Description

Performing a search on the Users admin screen is terrible and infuriating. Only the user_login (username) and user_nicename (sanitised username) fields are searched.

None of these fields are ever searched:

  • First name
  • Last name
  • Nickname
  • Display name

Email addresses are only searched if your search query contains an @ symbol.

On the Users screen in Network Admin, it gets worse. The user needs to be aware of the need to use a * wildcard character at the beginning and/or end of the search term, otherwise the search requires an exact match.

We should default to searching everything, all the time, with filters in place to revert the behaviour for large networks which need to control performance.

Attachments (4)

27304.patch (543 bytes) - added by mordauk 16 months ago.
27304.2.patch (555 bytes) - added by mordauk 3 months ago.
27304-tests.patch (1013 bytes) - added by mordauk 3 months ago.
27304.diff (3.0 KB) - added by wonderboymusic 7 days ago.

Download all attachments as: .zip

Change History (19)

comment:1 @SergeyBiryukov16 months ago

Related: #22309, #26839.

Last edited 16 months ago by SergeyBiryukov (previous) (diff)

comment:2 @mordauk16 months ago

Oh yes please. I've built searches a couple of times for sites that have front-end user directories and have always had to rely on custom queries.

@mordauk16 months ago

comment:3 @mordauk16 months ago

27304.patch sets the fields to be 'user_login', 'user_url', 'user_email', 'user_nicename', 'display_name', instead of just 'user_login', 'user_nicename'.

comment:4 @johnbillion16 months ago

#26839 was marked as a duplicate.

comment:5 @knutsp16 months ago

Please get this in soon.

comment:6 @AskKim16 months ago

Following here since you closed my original ticket. Glad to see you've got a patch for this headache.

comment:7 @johnbillion15 months ago

#18183 was marked as a duplicate.

comment:8 @MathSmath14 months ago

From a usability perspective, I think it's more complicated than just adding nicename and display name to the search. I think we also need first and last name from the usermeta.

On the user management screen, "Name" is one of the primary fields used to identify users. So you'd (reasonably) think it would be a key consideration in search. But the "name" that's listed is a combination of the first_name and last_name usermeta fields (not your display name or nicename).

If I, as a user, see someone listed named "Matt Smith", and I search for "Matt Smith" and get no results, I (understandably) think that search is broken.

I've also run into something that might be an edge case, but is worth mentioning: you're totally allowed to use the @ symbol in your username (or other user fields). So in assuming that anything with an "@" in it should only search the email field is wonky, IMO. But that's how it's currently implemented.

Aside: am I the only person who thinks there are too many "name" concepts in core? Login, nicename and display name in the users table, PLUS first name, last name and nickname stored in usermeta. Are any of these on the road to deprecation?

comment:9 @Lohoris14 months ago

You're not alone @MathSmath, they are definitely too many, when a single field would be enough, besides the username which should be used only to login anyway.

@mordauk3 months ago

@mordauk3 months ago

comment:10 @mordauk3 months ago

  • Keywords needs-testing added

27304.2.patch is a refreshed patch for the src/ version of trunk.

27304-tests.patch adds some unit tests for searching.

comment:11 @johnbillion3 months ago

  • Keywords 4.3-early has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to Future Release

comment:12 @obenland2 months ago

  • Owner set to johnbillion
  • Status changed from new to assigned

comment:13 @obenland2 months ago

  • Keywords 4.3-early removed
  • Milestone changed from Future Release to 4.3

@wonderboymusic7 days ago

comment:14 @wonderboymusic7 days ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 32980:

When searching for users using the search arg in get_users()/WP_User_Query, also search the user's email, url, and display name.

Adds unit tests.

Props mordauk, wonderboymusic.
Fixes #27304.

comment:15 @ocean9025 hours ago

  • Keywords dev-feedback added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Isn't this a duplicate of #16366? What about the concerns in ticket:16366:4?

Looks like the docs for user_search_columns needs to be updated if this stays.

Note: See TracTickets for help on using tickets.