[wp-hackers] Remove limit from WP_User_Search

Mike Schinkel mikeschinkel at newclarity.net
Fri Jul 23 14:27:30 UTC 2010


On Jul 23, 2010, at 10:10 AM, Simon Blackbourn wrote:
> 
> I've added an admin page from where the site owner can export names and
> email addresses of all users of a particular role, using WP_User_Search
> class:
> 
> $user_search = new WP_User_Search( '', '', 'member' );
> $results = $user_search->get_results();
> [...do stuff...]
> 
> But I can't figure how to remove the limit of 50 users that this defaults to
> - I need it to return all users. Can someone point me in the right
> direction?

Try either:

$user_search = new WP_User_Search( '', '', 'member' );
$user_search->users_per_page = PHP_INT_MAX;  // Or a very large number > #users
$results = $user_search->get_results();

Or try a hook in your theme's functions.php file:

add_action( 'pre_user_search', 'my_pre_user_search');
function my_pre_user_search($query) {
	$query->query_limit = '';
}

HTH.

-Mike



More information about the wp-hackers mailing list