How to create nodes "emulating" form submit I usually create and edit nodes, programmatically, using node_load and the node_save, and addind data to fields in this way:

$node-&gt;field_custom['lang'][0]['value'] = 'My value';


But in this way I've to check lang, and even if my node is "it" same fields (as terms, or other fields) need "und" and something like this.

Is there way to create and edit nodes loading the form and the submitting the form with new values?
Yep, look at drupal_form_submit.


  Retrieves, populates, and processes a form.
  This function allows you
  to supply values for form elements and submit a form for processing.
  Compare to drupal_get_form(), which also builds and processes a form,
  but does not allow you to supply values.
  There is no return value, but you can check to see if there are errors
  by calling form_get_errors().


// register a new user
$form_state = array();
$form_state['values']['name'] = 'robo-user';
$form_state['values']['mail'] = 'robouser@example.com';
$form_state['values']['pass']['pass1'] = 'password';
$form_state['values']['pass']['pass2'] = 'password';
$form_state['values']['op'] = t('Create new account');
drupal_form_submit('user_register_form', $form_state);


I find the easiest way to see what the form takes is to use the Net Panel in Firebug. Turn on Persist in Firebug and post your form, then look at the POST keys and values.