How To Find The ID Of All Registered Users?

WP_User_Query has an ‘exclude’ argument, which is designed to accept an array of user IDs to exclude. Since it will accept an empty array, when that’s the only parameter, the resulting object will contain all registered users. The most direct path to the IDs is via the $results property.

We can reduce $results to just user IDs, using wp_list_pluck() as shown below:

$user_query = new WP_User_Query( array( 'exclude' => array( )  ));
if ( ! empty( $user_query->results ) ) {
    $ids = wp_list_pluck( $user_query->results, 'ID' );
}

The variable $ids, now contains the IDs of all registered users.