Opened 10 years ago
Closed 10 years ago
#30064 closed enhancement (fixed)
WP_User_Query should support orderby => include
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Users | Keywords: | good-first-bug needs-unit-tests needs-patch |
Focuses: | Cc: |
Description
A la orderby
=> post__in
Attachments (3)
Change History (9)
#1
@
10 years ago
- Keywords has-patch added; needs-patch removed
30064_gowp1.diff is pretty straight-forward rip-off of the approach used in WP_Query
#2
@
10 years ago
- Keywords needs-unit-tests added
Thanks! Patch looks good at a glance, but we need to have some unit tests for the new orderby param.
#3
@
10 years ago
Please let me know if my patch is formatted correctly, this is the first one I've created.
#4
@
10 years ago
- Keywords needs-patch added; has-patch removed
jipmoors - Thanks for the updated patch. You're right that these values need sanitization. Because they're IDs, our preferred technique for sanization would be $include = implode( ',', array_map( 'intval', $qv['include'] ) );
. There should probably also be some sanity checks here to make sure that the value passed was an array (plus support for comma-separated strings, if this is a parameter that can be accessed via URL - I don't know off the top of my head, so this would need to be checked).
Re formatting: https://core.trac.wordpress.org/attachment/ticket/30064/30064_gowp1-2.diff Looks like your editor may be formatted for spaces rather than tabs.
#5
@
10 years ago
- Milestone changed from Future Release to 4.1
Thanks, jipmoors! The logic here is good, but can be condensed a bit - we have wp_parse_id_list()
to do all that array_filter()
, array_unique()
, etc. And since we need a parsed value for $include later on in the function, we can set it once at the top, and then use the parsed value below.
Adds support for 'orderby' => 'include'