Make WordPress Core


Ignore:
Timestamp:
09/14/2015 06:57:15 PM (10 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-user.php

    r33967 r34125  
    166166     *
    167167     * @since 3.3.0
     168     * @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter.
    168169     *
    169170     * @static
     
    171172     * @global wpdb $wpdb
    172173     *
    173      * @param string $field The field to query against: 'id', 'slug', 'email' or 'login'
     174     * @param string $field The field to query against: 'id', 'ID', 'slug', 'email' or 'login'.
    174175     * @param string|int $value The field value
    175176     * @return object|false Raw user object
     
    177178    public static function get_data_by( $field, $value ) {
    178179        global $wpdb;
     180
     181        // 'ID' is an alias of 'id'.
     182        if ( 'ID' === $field ) {
     183            $field = 'id';
     184        }
    179185
    180186        if ( 'id' == $field ) {
Note: See TracChangeset for help on using the changeset viewer.