#31220 closed defect (bug) (duplicate)
Add orderby meta_value_num to WP_User_Query
Reported by: | shyammakwana | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.0.1 |
Component: | Query | Keywords: | has-patch |
Focuses: | Cc: |
Description
For some reason, we cannot easily order the WP_User_Query()
by meta_value which is number without directly editing the SQL statements.
However, there is an way by adding a hook to pre_user_query works.
Attachments (2)
Change History (10)
#2
in reply to:
↑ 1
;
follow-up:
↓ 4
@
10 years ago
Replying to tyxla: thx,
will this be added in new version ?
@
10 years ago
Updating the patch - it now contains an updated version of the $orderby
query parameter documentation, which now includes meta_value_num
.
#3
@
10 years ago
Makes sense to me - this would be useful for sorting by numeric user meta.
I've just added a patch that:
- Addresses the capability to sort by
meta_value_num
; - Adds a unit test for that case;
- Updates the
$orderby
query parameter documentation to includemeta_value_num
.
Please, refer to the second patch 31220.2.patch, as it contains the documentation update.
#4
in reply to:
↑ 2
;
follow-up:
↓ 5
@
10 years ago
Replying to shyammakwana:
Replying to tyxla: thx,
will this be added in new version ?
@shyammakwana Hopefully, but I can't say for sure. Someone from the core team should decide whether this would go into the core, and in which version.
#5
in reply to:
↑ 4
@
10 years ago
Replying to tyxla:
Replying to shyammakwana:
Replying to tyxla: thx,
will this be added in new version ?
@shyammakwana Hopefully, but I can't say for sure. Someone from the core team should decide whether this would go into the core, and in which version.
thx,
it worked. However I have done it with pre_user_query
. temp. fix.
I hope, this will be added.
Adding
meta_value_num
orderby
option for WP_User_Query. Including a test for that case.