I've got a site with multiple domains using Domain Access. I want to display a search form on each site that searches for users on that site.
I'm using a modified version of the code here (that code works fine when searching for nodes) but it doesn't work. When searching it always return an empty result.
Here's my code:
/**
* Implements hook_entity_property_info_alter().
*
* Adds an entity property for the domain access of the user.
*/
function custom_search_users_entity_property_info_alter(&$info) {
$properties = &$info['user']['properties'];
$properties['custom_search_users_domain_access'] = array(
'label' => t('Domain Access Information'),
'description' => t('The domains to which the user has access.'),
'type' => 'list<integer>',
'getter callback' => 'custom_search_users_get_domain_info',
);
}
function custom_search_users_get_domain_info($data, array $options, $name, $type, $info) {
return (!empty($data->domain_user) ? $data->domain_user : NULL);
}
/**
* Implements hook_search_api_query_alter().
*
* Adds a filter for the current domain.
*/
function custom_search_users_search_api_query_alter(SearchApiQueryInterface $query) {
$domain = domain_get_domain();
$query->condition('custom_search_users_domain_access', $domain['domain_id']);
}
So basically what I've changed in my code is the use of $data->domain_user instead of $data->domain to comply with the user object.
Anyone got any idea of why this doesn't work?