Quote from: nunofil at Jul 29, 2013, 05:45 AMis there a way to contact the author about this? so no more people would have to go through this troubleshoot.
If you are looking for a one time import, skip all this.
Use phpMyAdmin. Create a dummy database and table. Import the csv. Export it as a PHP Array.
Iterate through the array via foreach.
In the loop add the user with modx->newObject
save the user.
With the user object API
- add the user to the group.
- force the password
save the user.
$profile= $userObj->getOne('Profile');
$profile->set('someField','someCsvColumnNameFromPhpExportArray['someField']');
Iterate through everything being imported to the profile and then $profile->save();
CSV is a poor mans way of exporting, but using Notepad++ or other decent editor you can change the field names listed in it to match the MODX ones and simply do something exotic like (from the top of my head - normal disclaimers of suitability, liability, and use at your own risk apply):
$userObj = $modx->newObject('modUser', $phparray);
$userObject->set('password', $phpArray['oldPassword');
$userObj->save();
$userObj->joinGroup('groupName'); // if you have a create a MODX user role then $userObj->joinGroup('groupName', 'roleName');
$profile = $userObj->getOne('Profile');
$newProfile = $profile->fromArray($phpArray);
$newProfile->save();
Note: do not try to directly import the old password. MODX has a very nice password mechanism and your old password simply will not work unless you use it. I don't even want to know how you would have a user's clear text password.....
You can always put a bogus one in there and send all of the users to Login's reset password function... Just saying.
References:
http://www.shawnwilkerson.com/modx-revolution/2012/03/10/programmatically-working-with-the-moduser-object/
http://www.shawnwilkerson.com/modx-revolution/2012/03/04/modx-revolution-object-cheat-sheet-moduser/
http://www.shawnwilkerson.com/modx-revolution/2013/07/29/modx-revolution-object-cheat-sheet-moduserprofile/ *new this morning