Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#33869 closed defect (bug) (fixed)

get_user_by() should accept ID as a field

Reported by: shelob9's profile Shelob9 Owned by: boonebgorges's profile boonebgorges
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.4
Component: General Keywords:
Focuses: Cc:


get_user_by() and WP_User::get_data_by() which it calls accept id but not ID as a value for the $field argument. This is counter-intuitive, since the DB column is "ID" not "id". I am attaching a patch to allow passing "ID", without breaking the use of "id".

Attachments (1)

33869.diff (897 bytes) - added by Shelob9 8 years ago.

Download all attachments as: .zip

Change History (5)

8 years ago

#1 @sc0ttkclark
8 years ago

+1 for consistency

#2 @boonebgorges
8 years ago

  • Milestone changed from Awaiting Review to 4.4

Thanks for the patch. I'll write a unit test and clean up the documentation.

#3 @boonebgorges
8 years ago

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

In 34125:

Accept 'ID' as a valid $field in get_user_by().

We already accept 'id'. ID more closely matches the database and
WP_User schemas.

Props Shelob9.
Fixes #33869.

This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.

7 years ago

Note: See TracTickets for help on using tickets.