Contribution Date
Technology
Contribution Project
Contribution Details
/**
* hook_apachesolr_index_document_build().
* @param ApacheSolrDocument $document
* @param unknown $entity
* @param unknown $entity_type
* @param unknown $env_id
*/
function hook_apachesolr_index_document_build(ApacheSolrDocument $document, $entity, $entity_type, $env_id) {
$uid = $entity->uid;
$user_data = user_load($uid);
$user_role = $user_data->roles;
foreach($user_role as $role) {
$document->setMultiValue('sm_user_role', $role);
}
}
/**
* hook_apachesolr_query_alter().
* @param unknown $query
*/
function hook_apachesolr_query_alter(&$query) {
// Add the parameter.
$query->addParam('fl', 'sm_user_role');
// Add filter of user role.
$query->addFilter('sm_user_role','administrator');
}
Contribution Issue Link
Files count
0
Patches count
0