Make WordPress Core

Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#21581 closed enhancement (fixed)

Add orderby meta_value to WP_User_Query

Reported by: wpsmith Owned by: wonderboymusic
Priority: normal Milestone: 3.7
Component: Users Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

For some reason, we cannot easily order the WP_User_Query() by last_name without directly editing the SQL statements. However, there is an easy way to add this that would work parallel to WP_Query().

// prepare arguments
$args  = array(
	'orderby' => 'meta_value',
	'meta_key' => 'last_name',
);
$user_query = new WP_User_Query( $args );

Attachments (1)

21581_user.patch​ (448 bytes ) - added by wpsmith 14 years ago.

Download all attachments as: .zip

Change History (11)

@wpsmith
14 years ago

#2 @iseulde
13 years ago

  • Component General → Query

#3 @wonderboymusic
13 years ago

  • Keywords 2nd-opinion dev-feedback removed
  • Milestone Awaiting Review → 3.7

Makes sense, patch still applies

#4 @hotchkissconsulting
13 years ago

Tested with latest trunk, patch works

#6 @c3mdigital
13 years ago

#17179 was marked as a duplicate.

#7 @SergeyBiryukov
13 years ago

  • Component Query → Users

Related: #23045

#8 @wonderboymusic
13 years ago

  • Owner set to wonderboymusic
  • Resolution → fixed
  • Status new → closed

In 25331:

Support orderby => meta_value in WP_User_Query. Adds unit test.

Props wpsmith.
Fixes #21581.

#9 @ocean90
13 years ago

  • Type defect (bug) → enhancement

#10 @christinecooper
12 years ago

deleted

Last edited 12 years ago by christinecooper (previous) (diff)
Note: See TracTickets for help on using tickets.