How to programmatically create new user with custom fields?
Using user_save Drupal function you can create new users like so:

$new_user = array(
  'name' =&gt; 'JohnDoe',
  'mail' =&gt; 'john.doe@email.com',
  'pass' =&gt; 'password123',
  'status' =&gt; 1,
  'field_custom_first_name' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt; 'John'))), // This becomes $account-&gt;field_custom_first_name[LANGUAGE_NONE][0]['value']
  'field_custom_last_name' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt; 'Doe'))),
  'access' =&gt; REQUEST_TIME,
  'roles' =&gt; array(), // No other roles than Authenticated
  //'roles' =&gt; array('10' =&gt; '10', '11' =&gt; '11'), // If you want to specify additional roles, the numbers are role_id's
);
user_save(NULL, $new_user);