Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function usersfilter_form_alter(&$form, &$form_state, $form_id) {
- global $user;
- if (in_array('administrator', array_values($user->roles))){
- return; //administrator
- }
- $newUsers = array();
- $existingUsers = $form['field_assign_to']['und']['#options'];
- foreach ($existingUsers as &$existingUser) {
- if($existingUser == $user->name){
- $newUsers[] = $existingUser;
- continue;
- }
- $account = user_load_by_name($existingUser);
- if (user_access('access administration pages', $account)) {
- $newUsers[] = $existingUser;
- continue;
- }
- }
- $form['field_assign_to']['und']['#options'] = $newUsers;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement