Best way to search users by a custom field inside a plugin? This did work until there’s a significant amount of users: 

$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::User);
$users = $criteria-&gt;search('customField:' . $someValue);


I’m using search as I need to find a value within the custom field. The field is typically 1,2,3 and I need to check for one of those values.

I have also tried to limit it without success.

$criteria-&gt;groupId = 1;
$criteria-&gt;limit = null;


What’s the best way to do this?

UPDATE:

The users getting missed are those that had the fields I’m searching populated by another plugin. This looks as though the data is not being saved in the same way as when it’s entered manually in the CP.
Does something like this work? You might need to add some wildcards as documented here to run the right kind of search.

$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::User);
$users = $criteria-&gt;search('customField: *' . $someValue.'*');