Revision: 40724
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 6, 2011 04:00 by JohnnyGamba
Initial Code
<?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
{
$time = time();
$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";
}
}
?>
Initial URL
Initial Description
Initial Title
create a new user with content profile
Initial Tags
drupal
Initial Language
PHP