i want import many users account and profile to drupal.
so i write a module and use druapl_execute to do this task. below is my code
// in update_N function
while($row = fgetcsv($fp)){
$fvalues['field_workgroup'][0]['value'] = $row[0];
$fvalues['name'] = $row[1];
$fvalues['mail'] = $row[1] .'@xxx.com';
$fvalues['field_realname'][0]['value'] = $row[2];
$fvalues['field_sex'][0]['value'] = $row[3];
$fvalues['pass']['pass1'] = $fvalues['pass']['pass2'] = (string)$row[4];
$fvalues['type'] = 'profile';
$form_state['values'] = $fvalues ;
drupal_execute('user_register', $form_state);
//dsm( $form_state);
}
the result is: only the first row`s user and profile was imported rightly,,
the rest of rows `s users was registered rightly but profile was lost totally.
ps. at same time a error message was given "warning: md5() expects parameter 1 to be string, array given in /.../modules/user/user.module on line 308."
so i insert a line dsm( $form_state) , i find some difference :
the first row: $form_state['content_profile_registration']['profile']['node'] is a object
the rest of rows : $form_state['content_profile_registration']['profile']['node'] is NULL
why and how to solve the problem?
ps . i also try to use batch api , but can`t work too.
Comments
Comment #1
afly commentedi find answer in http://drupal.org/node/260934#comment-1179304