how to save taxonomy terms in a custom user registration form in D7? I've got an Implementation of hook_form() on a custom page which I use for user registration.

For example I have this field:

function popover_form($form, &amp;$form_state){

    // some other fields are left out here to simplify my question

    $form['second']['education'] = array(
      '#type' =&gt; 'radios',
      '#title' =&gt; 'Afgeronde opleiding',
      '#options' =&gt; popover_get_tax_term_options('education'),
      '#default_value' =&gt; variable_get('education', NULL),
      '#required' =&gt; TRUE,
    );
    return $form;
}


Then in form_submit() I'm trying to do this:

function popover_form_submit($form, &amp;$form_state){
  $edit = array(

    // some other fields like username, email etc are also left out here.

    // field_firstname is a simple string and works.
    'field_firstname' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt; $form_state['values']['first']['field_firstname']))),
    // education doesn't work ( because it is a taxonomy term ? )
    'education' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt; $form_state['values']['second']['education']))),
  );
  user_save(drupal_anonymous_user(), $edit);
}


so either I need to change my submit handler because taxonomy terms are saved differently or I need to update the standard user edit 'view' ( $sitename/user/1/edit ) so the taxonomy terms become visible? Or I'm doing something else wrong?

EDIT:
I also found out that it is needed to connect taxonomy terms with the user on the admin/config/people/accounts/fields page before you can get this to work.
The column name for a taxonomy term reference is 'tid' rather than 'value', if you just change that your code should work:

$edit = array(
  'field_firstname' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt; $form_state['values']['first']['field_firstname']))),
  'education' =&gt; array(LANGUAGE_NONE =&gt; array(array('tid' =&gt; $form_state['values']['second']['education']))),
);

user_save(drupal_anonymous_user(), $edit);