我想隐藏用户列表中的某个用户(具有完全权限的技术管理员)。因为admin (另一个拥有较少权限的管理员)不会从用户列表中删除此管理员。虽然管理员可以从站点中删除其他用户。该怎么做呢?
发布于 2011-02-20 19:01:09
试试http://drupal.org/project/userprotect。
这是一个普遍的问题,管理用户权限是非常有问题的,并提供了太多的特权。
发布于 2011-02-23 07:29:39
使用视图复制用户列表,并在"Nid != hidden user's ID“上设置过滤器。
发布于 2016-11-01 18:08:38
您只需更改视图即可。转到查看>管理:用户>编辑。然后在筛选条件>添加>用户:角色中。在Operator中,选择Is none of,然后选择您想要隐藏的角色(管理员),点击apply并保存。完成了!
额外好处:您还可以通过在自定义模块中创建hook_form_alter()来隐藏此用户角色,使其不被注册(添加新用户)。如下所示:
/**
* Implements hook_form_alter().
*/
function MyModule_form_alter(&$form, &$form_state, $form_id) {
//to get the current user role
global $user;
$user_roles = $user->roles;
//use devel to find the user role, which you wish to hide
//dsm($form);
switch ($form_id) {
case 'user_register_form':
if (!in_array('administrator', $user_roles)) { // hide this only if the current user role is not administrator
unset($form['account']['roles']['#options'][3]);
}
break;
}
}这将在您创建新用户时隐藏administrator role。你也应该按照同样的方法从用户编辑表单中隐藏它。
https://stackoverflow.com/questions/5055939
复制相似问题