Search plugin only queries two results on user.php in admin panel

I have custom fields for users and want them displayed on the user's page in admin. I have a plugin that accomplished this, but it only queries two results.

  • Robert Andrews
    • WPMU DEV Initiate

    This ticket was created by WPMUDev following chat.

    The full description is actually...

    I am attempting to extend back-end User search to look beyond the standard WordPress profile fields, so that the search also encompasses several custom user meta fields I already have set up (the fields are from ACF, though the User data was imported directly).

    I have tried two methods...

    * The Better User Search plugin, which is built for exactly that and lets you specify extra fields for searching in the plugin frontend,
    * This code I found from Misha Rudrastyh, which uses a similar methods, pre_user_query, as far as I can tell,

    The problem:

    Whilst either of these methods (and Better User Search is my preferred) can successfully find results from the extended fields, when displaying them, the pagination is all wrong - just two results per listings page, even when there are hundreds of results.

    There is actually a weird relationship between the number of results page page and the number specified in Screen Options above...

    Was 150: only two displayed
    When 200: only two displayed
    When 400: four are displayed
    When 500: four are displayed
    When 600: five are displayed
    When 700: six are displayed
    When 800: six are displayed

    I have...

    * Stripped out pretty much every added function I can think of.
    * Disabled all plugins, to my knowledge.
    * Switched to the default Twenty Sixteen theme.
    * Never modified core files.
    * Searched for plugins using pre_get_users - it is only Admin Columns Pro, but that is disabled.

    ... But the result is still the same.

    I am running WordPress 4.8.1 using Multisite. When I install Better User Search on a separate standalone site, the pagination is all as it should be. But it does not work on my Multisite sub-site.

    This could be coincidental, ie. I may have failed to turn off a conflict, but I said I think I turned off as much as possible.

    What could be causing the pagination to go wonky here?

    • Robert Andrews
      • WPMU DEV Initiate

      Fair enough.

      1. I see the search works...
      I kept to the default fields. By the way, what is the correct way to set the standard and/or custom fields for search? I see input required at "// Usermeta fields to search" but also some other possible areas where I should provide input. Is that the only place?

      2. ... But the pagination problem remains! :slight_frown:
      I am still only getting two results per page.
      This is now the third method/piece of code to be tried on this.
      Where on earth is the problem standing in the way?

  • Adam Czajczyk
    • Support Gorilla

    Hello Robert!

    There were two pieces of code mentioned in this conversation and if I understand correctly, the paging issue occurs for both of them. Is that right?

    I assume you have modified these codes slightly to match your site's configuration (meta fields etc), so is there any "filtering" of the results involved? Could we actually see your codes (for both methods) as used on your site? You could share them either here or via e.g. service.

    Best regards,

  • Predrag Dubajic
    • Support

    Hi Robert,

    When I was testing the plugin you mentioned I was using email address, not custom meta, and with that I was able to replicate the issue with only 2 results showing but with the link I provided it worked fine and it listed all the users I was searching for, there were over 200 of them.

    So it's possible that this is some issue with the WP itself with custom meta or the code needs some further improvement but since this is custom development it goes bit beyond scope of the support that we can offer here, you can read more about that on this page:
    It might be best hiring a developer to investigate this further for you.
    We do have a job board where you can hire a developer to assist you with this:
    Please note that, no WPMU official staff members are allowed to work in the job board.

    When I signed up, I hadn't expected the 24/7 support would be an open forum.
    Does anyone have any further ideas, please?

    We offer both Chat and Forum support, and depending on the complexity of the question some require further investigation that can't really be handled via chat.
    Forums can be seen by everyone but only WPMUDEV members can post in them, we can also mark specific thread as private, if needed, and in that case only you and staff members will be able to see it and post in it.

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.