WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 10 days ago

#44169 new enhancement

New filter to short circuit WP_User_Query results

Reported by: tlovett1 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

#41700 added the filter posts_pre_query to WP_Query. This filter lets you short circuit the WP_Query MySQL query to return your own results. We use this filter in ElasticPress to return results from Elasticsearch instead of MySQL.

This ticket (patch incoming) is to add a similar filter to WP_User_Query.

Attachments (2)

users-pre-query-1.patch (2.7 KB) - added by tlovett1 5 weeks ago.
users-pre-query-test-1.patch (1.3 KB) - added by tlovett1 4 weeks ago.

Download all attachments as: .zip

Change History (6)

#1 @tlovett1
5 weeks ago

  • Keywords has-patch added

#2 @birgire
4 weeks ago

  • Keywords needs-unit-tests added

@tlovett1 Thanks for the patch.

It passes the current unit tests for the user group.

I will mark that this will need unit tests, if this goes forward.

Regarding the use cases, I can imagine this would be mostly used to override the search query of WP_User_Query, both front and backend?

I wonder if this could affect other processes? I don't think WP_User_Query is used during the login progress, but one could e.g. test what happens if WP_User_Query returns no users at all, during login.

ps: It seems that posts_pre_query was introduced to WP_Query ticket #36687.

#3 @tlovett1
4 weeks ago

  • Keywords has-unit-tests added; needs-unit-tests removed

Tests added.

#4 @tlovett1
10 days ago

Any update on this?

Note: See TracTickets for help on using tickets.