Searching for customFields

Hey there,

I am trying to search for all users that have a specific value in a specific custom field.
I guess my non-working code shows best what I am trying to do:

$userModel = new XenForo_Model_User();
$criteria = array(
       'customFields' => array("my_custom_field" => "bunny"),

$options = array(
       'join' => XenForo_Model_User::FETCH_USER_PROFILE,

$users = $userModel->getUsers($criteria, $options);
Also, how does the customFieldsExact work?

Daniel Hood

Well-known member
This actually looks like it should be working, what's it doing? Have you looked at the debug output for the query?

customFieldsExact requires an exact match. For example with our code it'd also match "abuNNy3" whereas if you use customFieldsExact it has to literally be "bunny".
I am getting all users in return, as if I hadnt specified any criteria.
How can I enable debug query, I am developing this piece of code in a custom file with the following header:
$fileDir = realpath(dirname(__FILE__) . '/../../');
require_once($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Phrase::setPhrases(require($fileDir . '/install/language_en.php'));
XenForo_Template_Install::setFilePath($fileDir . '/install/templates');