Saving custom fields for nodes and users I'm trying add a new user to drupal 7, here is my code:

$values = array('name' =&gt; $name, 'pass' =&gt; $password,  'mail' =&gt; $email, 'status'=&gt;1);
$newUser = user_save('', $values);


But i also have the new field field_foobar, if i add it to the values array drupal does nothing with it. What is the correct drupal way of adding these values to my user object so that drupal saves them when i call the user_save function?

I also saw that the fields are stored in the same type of table that stores custom fields of nodes. Also can't get this done, but i guess these 2 problems can have the same solution.

Thanks!
I haven't done this with user_save() before but if it follows convention from the rest of the system (which is likely) it'll be like this:

$values = array(
  'name' =&gt; $name, 
  'pass' =&gt; $password,  
  'mail' =&gt; $email, 
  'status'=&gt;1,
  'field_foobar' =&gt; array(
    LANGUAGE_NONE =&gt; array(
      0 =&gt; array(
        'value' =&gt; $field_value
      )
    )
  )
);

$newUser = user_save('', $values);


In fact there are a few examples further down the page in the user_save() docs confirming this method is the right one.