You are using array_merge in:

 function adminrole_admin_settings() {
   $form = array();
   $u_roles = user_roles();
   ksort($u_roles);
   $form['adminrole_adminrole'] = array(
     '#type' => 'select',
     '#title' => t('Admin Roles'),
     '#default_value' => variable_get('adminrole_adminrole', 0),
     '#description' => t("Which Role is Admin?"),
    '#options' => array_merge(array(0 => t('-- Please Select One --')), $u_roles),
   );
   return system_settings_form($form);
 }

But it's really buggy, because array_merge will rewrite the array indexes starting from 0, delinking the name to the real RID.

You have to use only the + operator, a simple concatenation, to preserve the indexes, like this:

 function adminrole_admin_settings() {
   $form = array();
   $u_roles = user_roles();
   $form['adminrole_adminrole'] = array(
     '#type' => 'select',
     '#title' => t('Admin Roles'),
     '#default_value' => variable_get('adminrole_adminrole', 0),
     '#description' => t("Which Role is Admin?"),
    '#options' => (array('-- Please Select One --') + $u_roles),
   );
   return system_settings_form($form);
 }

We don't need the ksort call, because the Selection text wil be ever 0, so the first item

Comments

marcingy’s picture

Status: Active » Closed (duplicate)