/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $query = db_query("SELECT * FROM {OldUserTable}"); while ($row = db_fetch_array($query) ) { $userData = array( 'name' => $row['ID'], 'pass' => $row['PASSWORD'], 'mail' => $row['EMAIL'], 'status' => 1, 'roles' => $role ); try { $new_user = user_save('', $userData); $good_count++; try { $profile_node = new stdClass(); $profile_node->title = $new_user->name; $profile_node->body = ''; $profile_node->type = 'profile'; // Your specified content type $profile_node->created = $time; $profile_node->changed = $time; $profile_node->status = 1; $profile_node->promote = 0; $profile_node->sticky = 0; $profile_node->format = 1; // Filtered HTML $profile_node->uid = $new_user->uid; // UID of content owner $profile_node->field_first_name[0]['value'] = $row['FIRST']; $profile_node->field_last_name[0]['value'] = $row['LAST']; $profile_node->field_location[0]['street'] = $row['ADDRESS']; $profile_node->field_location[0]['city'] = $row['CITY']; $profile_node->field_location[0]['province'] = $row['STATE']; $profile_node->field_location[0]['postal_code'] = $row['ZIP']; $profile_node->field_location[0]['country_name'] = 'United States'; $profile_node->field_location[0]['phone'] = $row['PHONE']; $profile_node->field_location[0]['fax'] = $row['FAX']; node_save($profile_node); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } ?>