In user profiles, I have added a term reference field. In my module, I want to get users that have a term id. Is there a function like taxonomy_select_nodes but for users to select users having a taxonomy term?


There isn't, but since users are entities, and taxonomy term references are fields, you can use an EntityFieldQuery to get this data. You could even wrap it in a function to make your life very easy:

function taxonomy_select_users($term_id) {
  $query = new EntityFieldQuery;
  $query->entityCondition('entity_type', 'user')
    ->fieldCondition('field_taxonomy_term_field', 'tid', $term_id);

  $results = $query->execute();

  if (isset($results['user'])) {
    return user_load_multiple(array_keys($results['user']));    

  return FALSE;
| improve this answer | |
  • That's the answer. – Abhijit Jul 2 '12 at 11:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.