1

I am building plugin which has a function to return any users that have a specific interest checked in their profile. The interests field is an array. What I need to do is check if the specific interest is in the interests array and only return users that have selected that interest. So far I have the following but this returns all users and not just users with the flagged interest. So how can I use the criteria model to check if the interest exists in the array?

$interest = craft()->request->getPost('interest');

//Get all users with specified interest
$user_criteria = craft()->elements->getCriteria(ElementType::User);
$user_criteria->interests = $interest;
$users = $user_criteria->find();

Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.