Custom fields in User registration, how to save? I thought that I needed to, in my submit handler function, call user_save() to save my user profile data.  But when I call user_save I get duplicate entry errors because it appears user_save is being called twice.

here's a snippet of code:

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


  $fname = $form_state['values']['field_first_name']['und'][0]['value'];
  $lname = $form_state['values']['field_last_name']['und'][0]['value'];


$edit = array(
  'name' =&gt; $form_state['values']['name'],
  'pass' =&gt; user_password(),
  'mail' =&gt; $form_state['values']['mail'],
  'init' =&gt; $form_state['values']['init'],
  'status' =&gt; 0,
  'access' =&gt; REQUEST_TIME,
    'field_first_name' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt;
$form_state['values']['field_first_name']))),

);


user_save(drupal_anonymous_user(), $edit);
&lt;snipped&gt;
If you insist use code I suggest below method 

function all_data_form_submit($form, &amp;$form_state) {
$fname = $form_state['values']['field_first_name']['und'][0]['value'];
$lname = $form_state['values']['field_last_name']['und'][0]['value'];
$name=trim($form_state['values']['name']);
$myuser=user_load_by_name($name);
if(!empty($myuser)){
        $edit = array(
                'field_first_name' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt;$form_state['values']['field_first_name']))),
                // .. and every field you want to save
                );
        user_save($myuser, $edit);
    }
}