A new website will help Seattle startups find worksites for rent or lease. Initially, worksite information will be bulk entered with a customized Node Import module. One data import field will be email. A module modification is needed to assign UID with an email lookup. If a UID is not found, a stub user account automatically would be created as node owner. Once a worksite node is imported, an anonymous user, who owns the associated email, could claim ownership with a request for new password.
Anyone who would like to help develop the custom Node Import module, provide technical support, or make suggestions in the comments is very welcome. After Seattle gets going, other cities could be added.
For background information:
http://drupal.org/project/node_import
http://www.communitywiki.org/odd/SiteFinder/HomePage
http://groups.google.com/group/shs-SiteFinder?hl=en
The next project meeting is scheduled for April 12.
=====================
Update: April 8 - 3am
Strategy: 1) Import users with email addresses; 2) Import nodes and assign to users with matching email addresses.
With the following code changes to node_import.module:
// $Id: node_import.module,v 1.50.2.3.2.13 2008/03/17 09:05:56 robrechtj Exp $
// Assign the mapped fields to the $node.
foreach ($row as $i => $value) {
if (!empty($match[$i])) {
$fieldname = $match[$i];
$node->$fieldname = $value;
}
// if ($match[$i] == 'name' && $type == 'node_import') {
// if (($account = user_load(array('name' => $value))) ||
// (is_numeric($value) && ($account = user_load(array('uid' => $value))))) {
// $node->uid = $account->uid;
// $node->name = $account->name;
// }
// else {
// $errors[] = t('The username %name does not exist.', array('%name' => $node->name));
// start replacement code
if ($fieldname == 'mail' && $type == 'node_import') {
$result = @db_query('SELECT uid FROM {users} WHERE mail = $value');
if (is_numeric($result) && ($account = user_load(array('uid' => $result)))) {
$node->uid = $account->uid;
$node->name = $account->name;
}
else {
$errors[] = t('A userid does not exist for %mail .', array('%mail' => $node->mail));
// end replacement code
}
}
}
Module links:
http://drupal.org/project/node_import
http://drupal.org/project/user_import
make code changes here: http://drupal.pastebin.org/28418
=====================================
Update: April 9 - 1am
I opened an issue under node import:
Assign node uid with user email - http://drupal.org/node/244367

Comments
Email Registration
http://drupal.org/project/email_registration
email_registration.module
function email_registration_user()
Could be called from Node Import module to create stub user account.
Other tips?
It's great
Hi, it's great. I find this sollution, too. I see it was integrated to the node import modul, but how did you do the auto user create procedure with imported email if no user found with that imported email?
Best Regards,
Krisz
auto user create procedure
Krisz,
I didn't create any special code for auto user create procedure.
If you are using 5.x you can take a two pass approach:
1. Run 5.x User import on user csv file: http://drupal.org/project/user_import
2. Run 5.x Node import on node csv file: http://drupal.org/project/node_import
I can't vouch for the above approach but it seems like a good way to get the job done.
If you find a better approach, be sure to leave a message.
BTW, it looks like the latest 5.x Node import module assigns users to nodes with imported email, but this feature is not well documented. I have not examined the 6.x version to see if it has that feature.
Cheers,
John