Fix for Fix for a hook_form_alter for user_profile_form

  1. function foo_form_alter(&$form, $form_state, $form_id){
  2.         switch ($form_id){
  3.                 case 'user_profile_form':
  4.                         global $user;
  5.                         /**
  6.                         *       Account Info subtab
  7.                         */
  8.                         if(is_array($form['account'])) {
  9.                        //Which roles have access to Blocking and Activating users
  10.                         if(!in_array('Administrator', array_values($user->roles))){
  11.                                 $form['account']['status']['#access'] = FALSE;
  12.                         }
  13.                                 //Keep Dealer Admins and Dealer Techs from changing roles
  14.                                 if(in_array('Dealer Admin', array_values($user->roles)) || in_array('Dealer Tech', array_values($user->roles))){
  15.                                         $form['account']['roles']['#access'] = FALSE;
  16.                                 }
  17.                         //Only one role allowed, changed from checkbox to select
  18.                         $roles = user_roles(TRUE);
  19.                                 $form['account']['roles']['#type'] = 'select';
  20.                         $form['account']['roles']['#options'] = $roles;
  21.                                
  22.                        
  23.                                 //Don't give people plaintext options since we're not using drupal's system for determining the content of EVERY email
  24.                                 $form['mimemail']['#access'] = FALSE;
  25.                     }
  26.                         /**
  27.                         *       Employee Information subtab
  28.                         */
  29.                         elseif(is_array($form['Employee Information'])){
  30.                                 $form['DMP Employee Information']['profile_department']['#type'] = 'select';
  31.                                 $form['DMP Employee Information']['profile_department']['#options'] = dmp_departments_get_array();
  32.                                
  33.                         }
  34.                         /**
  35.                         *       Dealer Information subtab
  36.                         */
  37.                         elseif(is_array($form['Dealer Information'])){
  38.                        
  39.                         }
  40.                     //Theme changing is unnecessary, hide it.
  41.                     $form['theme_select'] = NULL;
  42.                         unset($user);
  43.                 break;
  44.         }
  45. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.