Populate a hierarchical select field programmatically
I have saved user with custom hirerarical select field named "field_register_state" like below: it's working very well.

$account = new stdClass;
$account-&gt;is_new = TRUE;
$account-&gt;name = $username;
$account-&gt;pass = user_hash_password($form_state['values']['pass']);
$account-&gt;mail = $form_state['values']['mail'];
$account-&gt;init = $form_state['values']['mail'];
$account-&gt;status = TRUE;

$account-&gt;field_user_code = array(LANGUAGE_NONE =&gt; array(array('value'=&gt;$userCode)));
$account-&gt;field_full_name = array(LANGUAGE_NONE =&gt; array(array('value'=&gt;$form_state['values']['field_full_name']['und'][0]['value'])));
$account-&gt;roles = array(DRUPAL_AUTHENTICATED_RID =&gt; 'authenticated user',$form_state['values']['roles']=&gt;getRoleNameById($form_state['values']['roles'],$form));

$account-&gt;field_user_area_name = array(LANGUAGE_NONE =&gt; array(array('value'=&gt;$areaName)));
$account-&gt;field_created_by = array(LANGUAGE_NONE =&gt; array(array('value'=&gt;0)));
$account-&gt;field_register_state = array(LANGUAGE_NONE =&gt; array(array('tid'=&gt;$statecode)));
$account-&gt;timezone = variable_get('date_default_timezone'); 
user_save($account);
drupal_set_message(t('User Created Successfully'), 'status');


Hope this help's you..