Support » Plugin: Better User Search » Only returns two results per page

Viewing 2 replies - 1 through 2 (of 2 total)
  • This is the same problem as using code from https://rudrastyh.com/wordpress/pre_user_query.html

    eg.

    add_action('pre_user_query','rudr_extend_user_search');
     
     
    function rudr_extend_user_search( $u_query ){
    	// make sure that this code will be applied only for user search
    	if ( $u_query->query_vars['search'] ){
    		$search_query = trim( $u_query->query_vars['search'], '*' );
    		if ( $_REQUEST['s'] == $search_query ){
    			global $wpdb;
     
     			// let's search by users first name
    			$u_query->query_from .= " JOIN {$wpdb->usermeta} fname ON fname.user_id = {$wpdb->users}.ID AND fname.meta_key = 'first_name'";
     
    			// you can add here any meta key you want to search by
    			// $u_query->query_from .= " JOIN {$wpdb->usermeta} cstm ON cstm.user_id = {$wpdb->users}.ID AND cstm.meta_key = 'YOU CUSTOM meta_key'";
     
     			// let's search by all the post titles, the user has been published
    			$u_query->query_from .= " JOIN {$wpdb->posts} psts ON psts.post_author = {$wpdb->users}.ID";
     
     			// what fields to include in the search
     			$search_by = array( 'user_login', 'user_email', 'fname.meta_value', 'psts.post_title' );
     
     			// apply to the query
    			$u_query->query_where = 'WHERE 1=1' . $u_query->get_search_sql( $search_query, $search_by, 'both' );
    		}
    	}
    }

    Visible Users count in Screen Options is linked to the perverse output…

    – 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’ve stripped out other functions that could be causing a conflict and isolated this code. I turned off all plugins and switched to Twenty Sixteen and it’s still the same.

    I am running Multisite. The site in question is not the primary site.
    There are approx 4,500 users.

    Whilst the plugin throws the above problem on my Multisite site, it works fine on my standalone site.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.