I created a user view and their roles and applied multiple roles to the users.
I do not want to show the (anonymous,authenticated user,role1,role2) in the
views output ,im trying to render using views_pre_render as well as
views_post_execute but its displaying as anonymous,authenticated
user,role1,role2,MyROLE1,MYROLE2 for the Roles column
I created a custom module
My code below :
function customview1_views_post_execute(&$view) {
$results = &$view->result;
foreach ($results as $key => $result) {
if ($view->name == 'list_users_roles') {
$user_roles = $result->_field_data['uid']['entity']->roles;
// print_r($result->_field_data['uid']['entity']->roles);
$filtered_roles = array_values(array_diff($user_roles,array('anonymous user','authenticated user','role1','role2'))) ;
$results[$key]->_field_data['uid']['entity']->roles['rendered']['#markup'] = $filtered_roles;
}
}
return $view;
}