0

I'm using Administer Users by Role module and I crated a view of users.
That view displays all the users.
Lets assume there is 'Admin', 'Editor' & 'Member' roles.
Admin can see all the users.
Editor can see only Members (not other Editors and not the admin).
I need that so I can use Views-Data-Export module.

How to create such a view? or any other suggestions?

1

I don't know whether this is correct or not but you can try this,

function mymodule_views_query_alter(&$view, &$query) 
{
 global $user;
 $role=implode(', ', array_slice($user->roles, 1));//get the current user role
if ($view->name == 'your_view_name') 
{
  switch ($role) {
    case 'administrator':
//  drupal_set_message("administrator");
     // $query->add_where(); put your where condition
     // $view->query->set_group_operator('OR');
        break;
    case 'editor':
//  drupal_set_message("editor");
     // $query->add_where(); put your where condition
     // $view->query->set_group_operator('OR');
        break;
    case 'Member':
    //  drupal_set_message("Member");
      // $query->add_where(); put your where condition
     // $view->query->set_group_operator('OR');
        break;
        }
    } 

}
  • If it's a Member how to cancel the query? – NickF Dec 17 '13 at 15:33
  • If it is member than call the empty view result..or you can make a condition on where clause. – madhurjya Dec 17 '13 at 17:31

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.