"An illegal choice has been detected" error on user creation
When you submit a form Drupal checks the integrity of it, i.e. it checks that the submitted values fall in line with the list of possible values for each element in the original form definition.

So, if you've got a select/checkboxes/radio buttons element on the form and you change the possible options for this using javascript on the client side, the new options won't match up with the ones Drupal knew about when the form was built. In this instance Drupal will rightly inform the user "An illegal choice has been detected.", because it has. This is an excellent security feature and is the default behaviour. It can't be switched off without some serious effort.

I would take a guess in your case that this problem is happening in the JS you're attaching to the autoassignrole_user element.

If you want to change a form's structure using JS you need to do it the 'Drupal' way, using AJAX to update the form on the server-side:

function MYMODULE_my_form($form, &amp;$form_state) {
  // If the checkbox is ticked, load one set of options
  if (isset($form_state['values']['check']) &amp;&amp; $form_state['values']['check']) {
    $options = new_options();
  }
  else {
    // Otherwise load the default options
    $options = default_options();
  }

  $form['check'] = array(
    '#type' =&gt; 'checkbox',
    '#title' =&gt; 'Click to change options',
    '#default_value' =&gt; isset($form_state['values']['check']) ? $form_state['values']['check'] : 1,
    '#ajax' =&gt; array(
      'wrapper' =&gt; 'options-wrapper',
      'callback' =&gt; 'my_form_ajax_callback'
    )
  );

  $form['options'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; 'Options',
    '#options' =&gt; $options,
    '#prefix' =&gt; '&lt;div id="options-wrapper"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;'
  );
}

function my_form_ajax_callback(&amp;$form, &amp;$form_state) {
  // Return the options element which will have been changed in the re-build of the form
  return $form['options'];
}


The above is a very simple AJAX example that uses a checkbox change event to change the values in a select list on the form. Doing it this way will keep the internal structure of the form intact and you will no longer get the error message you're currently getting.

Have a look at the Form API documentation and AJAX framework documentation for a lot more information on this.