[wp-trac] [WordPress Trac] #57731: Bug: WP_User_Query returns wrong user details

WordPress Trac noreply at wordpress.org
Thu Feb 16 09:52:18 UTC 2023


#57731: Bug: WP_User_Query returns wrong user details
-------------------------------------------------+-------------------------
 Reporter:  ak.singla                            |      Owner:  (none)
     Type:  defect (bug)                         |     Status:  new
 Priority:  normal                               |  Milestone:  Awaiting
                                                 |  Review
Component:  Query                                |    Version:  6.1.1
 Severity:  major                                |   Keywords:
  Focuses:  administration, template, rest-api,  |
  performance, coding-standards                  |
-------------------------------------------------+-------------------------
 Hello,

 I am using the below code to fetch the user from the database.

 {{{
     $user_query_args = array(
         'search'         => 'abc at email.com',
         'search_columns' => ['user_email', 'ID']
     );
     $user_query = new WP_User_Query($user_query_args);
 }}}

 My Findings:

 **If the email does not start with numeric digits**''''
 Case 1:
   - Email: abc at email.com
   - User exists with above email
   - Works fine.


 **If the email starts with numeric digits**''''
 Case 2:
   - Email: 123abc at email.com
   - User exists with the above email
   - Work fine.

 Case 3: (INVALID RESULTS)
   - Email: 123abc at email.com
   - User DOES NOT exist with the above email
   - **Does not work as intended and returns the user data of the user with
 ID: 123, instead of returning 0 results**

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57731>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list