Searching for WordPress users by id.

Updated: 01 November 2022

From the Users screen

Searching for a WordPress user by ID is fairly straightforward from the Users Screen. Simply enter a user ID in the ‘Search Users’ box and press the button. Although the documentation ( states:
Any User that contains the search string in the Username, Name, E-mail, or Website fields will be displayed, by Role.
searching by ID also works.

Looking at the source code for class WP_Users_List_Table ( the user search is carried out using an instance of class WP_User_Query. If the search columns are not specified default search columns are set depending on the search term. If the search term is numeric the search columns default to user_login and ID (see Incidentally, this means that purely numeric search terms will not match email addresses.

From the command line

The syntax for searching for a WordPress user by ID using WP CLI is a bit obscure. The relevant section of the documentation for wp user list is:

    Control output by one or more arguments of WP_User_Query().

The documentation for WP_User_Query includes the search argument, which is the necessary field. (See

Example: wp user list --search=317

As a side note, it is also possible to search by role using WP CLI.

Example: wp user list --role=subscriber

Leave a comment