I am trying to turn this query to drupal EntityCondition query
select u.name, ',', u.mail, ',', r.name , ','
from users as u, users_roles as ur, role as r
where u.uid = ur.uid
and ur.rid = r.rid
This should return a list of all users with their email username and user role
I have this
$query = new EntityFieldQuery;
$query
->entityCondition('entity_type', 'user')
->addTag('role_filter');
$results = $query2->execute();
So getting all users within a specific role id
function mymodule_query_role_filter_alter(QueryAlterableInterface $query) {
$query->leftJoin('users_roles', 'r', 'users.uid = r.uid');
$and = db_and()
->condition('r.rid', array(3,4,5), 'IN');
$query
->condition($and);
}
I am not sure how to get the role value based on what I have is it another entity condition?
The above entityFiledQuery does return the following
{"1":{"uid":"1","name":"admin","pass":"HASHPASSWORD!","mail":"[email protected]" "roles":{"2":"authenticated user","3":"administrator"},
but a) I would rather have roles as the value administrator and not this funky array with the "rid" key b) the hashed password is there, can data be sanitized ?
mymodule_
as a prefix (ormytheme_
for themes).