diff --git a/wp-includes/class-wp-object-query.php b/wp-includes/class-wp-object-query.php index fcb04b1e2..240d68de1 100644 --- a/wp-includes/class-wp-object-query.php +++ b/wp-includes/class-wp-object-query.php @@ -233,8 +233,12 @@ class WP_Object_Query { $string = esc_sql( $string ); $searches = array(); - foreach ( $cols as $col ) - $searches[] = "$col LIKE '%$string%'"; + foreach ( $cols as $col ) { + if ( 'ID' == $col ) + $searches[] = "$col = '$string'"; + else + $searches[] = "$col LIKE '$string%'"; + } return ' AND (' . implode(' OR ', $searches) . ')'; } diff --git a/wp-includes/user.php b/wp-includes/user.php index 373b33e84..6734f1514 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -446,7 +446,16 @@ class WP_User_Query extends WP_Object_Query { $search = trim( $qv['search'] ); if ( $search ) { - $this->query_where .= $this->get_search_sql( $search, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'display_name' ) ); + if ( false !== strpos( $search, '@') ) + $search_columns[] = array('user_email'); + elseif ( is_numeric($search) ) + $search_columns = array('user_login', 'ID'); + elseif ( preg_match('|^https?://|', $search) ) + $search_columns = array('user_url'); + else + $search_columns = array('user_login', 'user_nicename', 'display_name'); + + $this->query_where .= $this->get_search_sql( $search, $search_columns ); } $this->parse_meta_query( $qv );