How to create user programatically in Drupal 6 and 7

Warning message

JQuery Cycle must be installed in order to run the slideshow. Please go to Status Report for instructions.

In Drupal 6 you can for the FORM API :


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