elliotcondon/acf — pull request #201 by haroldkyle (2013-11-25 20:08:05+00:00)
Title: Adding support to pre-filter the user IDs to include in an individual user field query.

I added a filter to the /core/fields/user.php to allow me to pre-filter the user IDs returned in any particular user field. My situation was that I needed to narrow the list of Users in a way other than a User Role. The dropdown had almost 20,000 elements because the Users I needed spanned all Roles. So, I pass an array of IDs to limit the search by to narrow down the role-based queries. In my case, I am pre-filtering by user taxonomy to only show users with the "calligrapher" taxonomy term applied:
```php
add_filter('acf/include_users/id=acf-field-calligrapher', function( $include ){
$calligrapher_term = get_term_by( 'slug','calligrapher','user_types' );
$users_in_taxonomy = get_objects_in_term( $calligrapher_term->term_id, 'user_types' );
return array_merge( $users_in_taxonomy, $include );
});
```
Not sure if the handle or the use of `$field['id']` is appropriate, but that's what seemed the most sensible to me.