Making WordPress.org

Changeset 3894


Ignore:
Timestamp:
08/31/2016 06:54:48 PM (8 years ago)
Author:
coffee2code
Message:

Profiles Activity Handler: Allow 'user' field to accept an integer value (for user id).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/profiles.wordpress.org/public_html/wp-content/plugins/wporg-profiles-activity-handler/wporg-profiles-activity-handler.php

    r3893 r3894  
    4848
    4949        /**
    50          * Gets a user by either login or slug.
    51          *
    52          * @param string         $username The user's login or slug.
     50         * Gets a user by either login, slug, or id.
     51         *
     52         * @param string|int     $username The user's login, slug, or id.
    5353         * @return WP_User|false WP_User object on success, false on failure.
    5454         */
    5555        protected function get_user( $username ) {
    56             $user = get_user_by( 'login', $username );
     56            if ( is_numeric( $username ) && ( absint( $username ) == $username ) ) {
     57                $user = get_user_by( 'id', $username );
     58            } else {
     59                $user = get_user_by( 'login', $username );
     60            }
    5761
    5862            if ( ! $user ) {
    59                 $user = get_user_by( 'slug', $username );
     63                $user = get_user_by( 'slug', strtolower( $username ) );
    6064            }
    6165
Note: See TracChangeset for help on using the changeset viewer.