How to form_later the user profile form to only allow 1 role to be assigned/removed I want to restict my site editors ( a role ) to only be able to select/deselect the role 'subscriber' and not be able to meddle with the other role assignments.  I have tried the following to remove the other roles :

case 'user_profile_form':
  global $user;
  if(in_array('site editor', $user-&gt;roles)  &amp;&amp; !in_array('administrator', $user-&gt;roles)) {
    unset($form['account']['roles']['#options']['3']);  // administrator
    unset($form['account']['roles']['#options']['4']);  // site editor
  }


However this has the effect of both hiding the checkboxes and un-assigning the roles.  I want any existing assignments to these roles to persist.

Your help appreciated.
Roles are removed because when the form is submitted those roles are missing (and thus unchecked). You can hide those options instead:

$form['account']['roles']['3'] = array(
  '#disabled' =&gt; TRUE,
  '#attributes' =&gt; array('class' =&gt; array('hidden'))
);


And some CSS .hidden { display: none; } or something.


  In D7+, form_process_checkboxes() and form_process_radios() already support you in doing so by allowing for partial sub-element pre-definitions read more