function administerusersbyrole_form_user_admin_account_alter in Administer Users by Role 7.2
Implements hook_form_FORM_ID_alter().
File
- ./
administerusersbyrole.module, line 160 - Provides fine-grained permissions for creating, editing, and deleting users.
Code
function administerusersbyrole_form_user_admin_account_alter(&$form, &$form_state, $form_id) {
if (!user_access('administer users')) {
// Remove rows if user doesn't have permission to edit them.
// This deliberately removes users with cancel access but not edit access. Although it seems attractive to keep them,
// please DO NOT change this behaviour. If we did, then users would be able to run bulk edits on other users
// when having cancel permission but no edit permission.
foreach ($form['accounts']['#options'] as $uid => $fields) {
$account = user_load($uid);
// This form exposes operations such as block account that shouldn't be available on a user's own account,
// so just check our own permissions.
if (!_administerusersbyrole_check_access($account, 'edit')) {
unset($form['accounts']['#options'][$uid]);
}
}
}
}