t('Apply only to'), '#type' => 'checkboxes', '#checkall' => TRUE, '#options' => $roles, '#default_value' => _user_role_field_roles($field), '#description' => t('Use these options to make a field visible for a specific role. If no role is set, the field is visible to all roles. If "Display on user registration form" is ticked and some roles have been set here, make sure to set the anonymous user role as well, else the field will not be shown.'), '#weight' => -1, ); // Hide the option to non-privileged users. if (!user_access('administer user field roles')) { $form['field']['settings']['user_role_field']['#type'] = 'value'; $form['field']['settings']['user_role_field']['#value'] = $form['field']['settings']['user_role_field']['#default_value']; } }