MyBB Community Forums

Full Version: Adding users
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
is there a way of adding users in bulk to the mybb forum system ?

i tried by using .csv file into mysql but they all inputted but no-one could login !!!!!!! Sad

please help !
There currently isn't a mass input tool.

When you imported them using a CSV file, what format were the passwords in?
Thanks for replying!

The passwords were in normal text format, is this the problem?

Are they stored as MD5 ????
There are a number of things that you have to make sure you have in your import

- username
- password (MD5'd)
- email (trust me on this one...you DO NOT want to have a bunch of users with no email-address in the system and then one of them goes to use the Lost Password-function and you end up like me...getting over 13,000 email-failure messages in your inbox)
- groupid
- I am not sure if this is necessary but registration-date (regdate)...you could import it from your source (if you have it) or just give everyone the same


I think that would do it...you can leave the salt empty as it will be created then with their first login... You can always then add other stuff later (allownotices would be the first I would think of)

So if you have the records already in, just make sure that the values in the password-field are MD5'd.

cheers,
Kimmo
ooops...Chris was faster than me.....serves me right for trying to do my paying job at the same time as writing here Smile
but how do i md5 the passwords before importing them?
md5 passwords is done by default this way


$password = 123;
$md5password = md5($password);

in mybb, the passwords are also salted

$salt = generate_salt();
$saltedpw = salt_password($md5password, $salt);

regards
Quote:but how do i md5 the passwords before importing them?

You'd have to use a PHP script or similar to do it for you and then change the plain text password in the file for each user to the new MD5'd psasword.

If you import the users again with the plain text passwords, the following script will MD5 them for you.

PHP Code:
<?php
/**
 * MyBB 1.2
 * Copyright � 2006 MyBulletinBoard Group, All Rights Reserved
 *
 * Website: http://www.mybboard.com
 * License: http://www.mybboard.com/eula.html
 *
 * $Id$
 */

$query $db->query("SELECT uid,password FROM ".TABLE_PREFIX."users");
while(
$user $db->fetch_array($query))
{
    
$db->query("UPDATE ".TABLE_PREFIX."users SET password='".md5($user['password'])."' WHERE uid='".$user['uid']."'");
}
echo 
"Converted passwords to MD5 hashes.";
?>

Throw it in your MyBB directory.

Please also make sure, as Kimmo said, you're also importing email addresses (if you have them) and are setting the usergroup of the users (2 is the default for normal registered users).

Quote:in mybb, the passwords are also salted
A little tip - if you import the users and the loginkey/salt fields are blank MyBB will then encrypt the password with a new salt when the user logs in. So as long as your passwords are md5'd and the salt field is blank, MyBB will fix it all up for you.

Regards,
Chris
I am not sure if it works (I didn't try it) but you could try to wrap the cleartext password like this:

md5(cleartextpassword)

so if you already wrote the cleartextpasswords in the password field, then something like this should work:

UPDATE mybb_users SET password=md5(password);
DISCLAIMER!!!!
Do not use it until someone can verify what I am saying as this will mess with all the users in the usertable.... I have NOT TRIED this and am not an expert on the matter!

You can also remove your imported records and re-import them but this time in your code you have to use the wrapper md5() mentioned above..

cheers,
Kimmo

UPDATE:
---------
I tried the
UPDATE mybb_users SET password=md5(password);

in a small test-database on MySQL with PHPMyadmin and it worked fine....but use at your own risk....at least have a backup of the table ready (there are only 2 kinds of people in the world, those who have lost data and those who are about to lose data (actually there are only 10 different kinds of people in this world...those who understand binary and those who don't))
Kimmo, that works as long as none of the passwords are already hashed. If you have hashed passwords in there already, use a WHERE clause to limit its effects.