Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 10 years ago

#21581 closed enhancement (fixed)

Add orderby meta_value to WP_User_Query

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


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 12 years ago.

Download all attachments as: .zip

Change History (11)

12 years ago

#2 @iseulde
11 years ago

  • Component changed from General to Query

#3 @wonderboymusic
11 years ago

  • Keywords 2nd-opinion dev-feedback removed
  • Milestone changed from Awaiting Review to 3.7

Makes sense, patch still applies

#4 @hotchkissconsulting
11 years ago

Tested with latest trunk, patch works

#6 @c3mdigital
11 years ago

#17179 was marked as a duplicate.

#7 @SergeyBiryukov
11 years ago

  • Component changed from Query to Users

Related: #23045

#8 @wonderboymusic
11 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 25331:

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

Props wpsmith.
Fixes #21581.

#9 @ocean90
11 years ago

  • Type changed from defect (bug) to enhancement

#10 @christinecooper
10 years ago


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