1

I’m working on a search form which filters the users . Everything works but the result is always limited to 299 users.

Here is my code which is vers basic :

$args = array(
        'orderby' => 'ID', 
        'meta_query' => $query_array,
    );

$user_query = new WP_User_Query($args);

If i add 'number' => 999999,

$args = array(
        'number'    => 999999,
        'orderby' => 'ID', 
        'meta_query' => $query_array,
    );

It doesn’t work, i’m still limited to 299

If i had 'number' => 150,

It works, the number of result is limited to 150.

I don’t see anything related to this limit in the codex : https://codex.wordpress.org/Class_Reference/WP_User_Query

Maybe, the issue is not directly related to WP_User_Query but i need to be sure that there is not a limit established by WP_User_Query.

  • 1
    Use 'number' => -1 to query all users. – Nathan Johnson Apr 3 '17 at 16:13
  • 2
    there is no limit and the default is to query all users. I suspect some plugin is hooking into either pre_get_users or pre_user_query and setting $args['number']. To find out, deactivate all plugins and see if you get all users. If so, then reactivate them 1 at a time until you no longer do and you'll know which plugin is doing it. – Paul 'Sparrow Hawk' Biron Apr 3 '17 at 16:42
  • 1
    Alternatively, you can install the Query Monitor plugin and check it's Hooks output to see what is hooking into either of those. – Paul 'Sparrow Hawk' Biron Apr 3 '17 at 16:42
  • I’ve already tried 'number' => -1 and it is still limited to 299. I’ll deactivate all plugins and hook. – Sébastien Gicquel Apr 3 '17 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.