Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#31220 closed defect (bug) (duplicate)

Add orderby meta_value_num to WP_User_Query

Reported by: shyammakwana's profile 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)

31220.patch (1.5 KB) - added by tyxla 10 years ago.
Adding meta_value_num orderby option for WP_User_Query. Including a test for that case.
31220.2.patch (2.6 KB) - added by tyxla 10 years ago.
Updating the patch - it now contains an updated version of the $orderby query parameter documentation, which now includes meta_value_num.

Download all attachments as: .zip

Change History (10)

@tyxla
10 years ago

Adding meta_value_num orderby option for WP_User_Query. Including a test for that case.

#1 follow-up: @tyxla
10 years ago

  • Keywords has-patch added

#2 in reply to: ↑ 1 ; follow-up: @shyammakwana
10 years ago

Replying to tyxla: thx,
will this be added in new version ?

@tyxla
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 @tyxla
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 include meta_value_num.

Please, refer to the second patch 31220.2.patch, as it contains the documentation update.

Last edited 10 years ago by tyxla (previous) (diff)

#4 in reply to: ↑ 2 ; follow-up: @tyxla
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 @shyammakwana
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.

#6 @jdgrimes
10 years ago

Looks like a duplicate of #27887.

#7 @tyxla
10 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Indeed, this is a duplicate of #27887. I'll post my patch there.

#8 @ocean90
10 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.