Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Scripting creation of users in database

edited August 2006 in Vanilla 1.0 Help
Hi I have to create around 150 users on a vanilla installation since I want to simplify the experience for the users. Does anybody know which fields I _need_ to fill out in the LUM_User table? Are there any other dependencies I need to fill in? What encryption is used to the passwords? MD5?

Comments

  • Have you looked at the CreateUser function in the People UserManager (i think) class?
  • Thanks! I'll take a look at that!
  • I want to do the same thing. I am hoping to make the move from the website to the forum as seamless as possible for the user. After populating the user table with a standalone script, I'm going to have to add this stuff to my registration process and (I believe) plug the registration process on the vanilla forum. I want them coming in the "front door" of my application. Has anyone done all this before? It seems as though there would be a lot of situations requiring this sort of integration. Is there a "how to" anywhere? The steps should be labeled "How to integrate Vanilla into an existing website which already has a login".
  • see this post: http://lussumo.com/community/discussion/3381/
  • I wrote my ugly hack which I have included below. It is quite unsecure as I just drop it and the user/password file into my vanilla root and do % php createusers.php Or you could just visit the php-file in a browser. If you use this, make sure you remove the two files from your vanilla directory afterwords. There are a lot of things which are not "proper" with this script, such as no email. This however is because I do not know my users email adresses yet. Use at your own risk :) <?php include("appg/settings.php"); $Configuration['SELF_URL'] = 'urlpage.php'; include("appg/init_people.php"); $lines = file('file with logins/passwords'); foreach ($lines as $line) { // choose your own delimiter $columns = split(';', $line); // you choose your columns $username = $columns[1]; $pw = $columns[2]; $email = ""; $Applicant = $Context->ObjectFactory->NewContextObject($Context, 'User'); $Applicant->Name = $username; $Applicant->Email = $email; $Applicant->NewPassword = $pw; $Applicant->ConfirmPassword = $pw; $Applicant->AgreeToTerms = true; $UserManager = $Context->ObjectFactory->NewContextObject($Context, 'UserManager'); $SafeUser = clone($Applicant); $SafeUser->FormatPropertiesForDatabaseInput(); $s = $Context->ObjectFactory->NewContextObject($Context, 'SqlBuilder'); $s->Clear(); $s->SetMainTable('User', 'u'); $s->AddFieldNameValue('FirstName', $SafeUser->FirstName); $s->AddFieldNameValue('LastName', $SafeUser->LastName); $s->AddFieldNameValue('Name', $SafeUser->Name); $s->AddFieldNameValue('Email', $SafeUser->Email); $s->AddFieldNameValue('Password', $SafeUser->NewPassword, 1, 'md5'); $s->AddFieldNameValue('DateFirstVisit', MysqlDateTime()); $s->AddFieldNameValue('DateLastActive', MysqlDateTime()); $s->AddFieldNameValue('CountVisit', 0); $s->AddFieldNameValue('CountDiscussions', 0); $s->AddFieldNameValue('CountComments', 0); $s->AddFieldNameValue('RoleID', 3); $s->AddFieldNameValue('StyleID', 0); $s->AddFieldNameValue('UtilizeEmail', 0); $s->AddFieldNameValue('Attributes', ''); $s->AddFieldNameValue('RemoteIp', GetRemoteIp(1)); print "Inserting user " . $SafeUser->Name . " into database...\n"; $User->UserID = $Context->Database->Insert($s, "UserManager", 'CreateUser', 'An error occurred while creating a new user.'); // Role stuff I guess... $Urh = $Context->ObjectFactory->NewObject($Context, 'UserRoleHistory'); $Urh->UserID = $User->UserID; $Urh->AdminUserID = 0; $Urh->RoleID = 3; // always accept registration $Urh->Notes = $Context->GetDefinition('RegistrationAccepted'); $UserManager->AssignRole($Urh, 1); } ?>
  • edited August 2006
    That should be enought:<?php include("appg/settings.php"); $Configuration['SELF_URL'] = 'urlpage.php'; include("appg/vanilla_people.php"); $lines = file('file with logins/passwords'); foreach ($lines as $line) { // choose your own delimiter $columns = split(';', $line); // you choose your columns $username = $columns[1]; $pw = $columns[2]; $email = ""; $Applicant = $Context->ObjectFactory->NewContextObject($Context, 'User'); $Applicant->Name = $username; $Applicant->Email = $email; $Applicant->NewPassword = $pw; $Applicant->ConfirmPassword = $pw; $Applicant->AgreeToTerms = true; $UserManager = $Context->ObjectFactory->NewContextObject($Context, 'UserManager'); $UserManager->CreateUser($Applicant); } ?>
This discussion has been closed.