I've read that the WP REST API v2 retrieves only users that have made a post for the blog. I'm developing an iOS and Android app that needs to use the Wordpress registration.

How I could retrieve a list of all users registered to my Wordpress blog? Even those that never wrote a post?


1 Answer 1


Thanks to stackoverflow user Milap !

You can get all users even they have not created any post, for that you need to modify rest-api plugin.

Open wp-content/plugins/rest-api/lib/endpoints/class-wp-rest-users-controller.php file, you will find below code on line number 106,

if ( ! current_user_can( 'list_users' ) ) {
    $prepared_args['has_published_posts'] = true;

Change it to below,

if ( ! current_user_can( 'list_users' ) ) {
    $prepared_args['has_published_posts'] = false;

If you don't want to modify plugin, put below code into current theme's functions.php file.

add_filter( 'rest_user_query' , 'custom_rest_user_query' );
function custom_rest_user_query( $prepared_args, $request = null ) {
  return $prepared_args;

You are done.

FYI: i choose to edit the API file and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.