Bulk import users by writing directly to users table - Printable Version +- MyBB Community Forums (https://community.mybb.com) +-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html) +--- Forum: General Support (https://community.mybb.com/forum-176.html) +--- Thread: Bulk import users by writing directly to users table (/thread-207314.html) |
Bulk import users by writing directly to users table - strix - 2017-01-11 Hi, I'm helping out with a new installation of MyBB (1.8) for an established community that presently uses Google Groups. Before that, it was a mailman mailing list for maybe 15-20 years or so. So there are a fair few users and the transition is going to be painful enough for some of them. I'd like to make this as simple as possible by pre-creating accounts for them, and entering them manually isn't an option. There is a ModX format mod, but it appears to be for an earlier version of MyBB, and I can't find any equivalent on the new MyBB plugins site. I'm handy enough with SQL and scripting (I prefer Python, but I can write PHP at a push) and quite comfortable with vim and remote shell, so my question is: Can I get away with writing a script to generate a username and password, insert rows into directly into the users table (and email the user with their pw)? Or do I need to mess with other tables? I figure that a minimum set of fields would be username, password, salt, email and usergroup (registered users). Should I use an existing row as a template, or will leaving everything else empty provide sane defaults? Or perhaps I would do better by instantiating whatever is the user class? (A hint of where to find that and what is required to instantiate it would be welcome!) How is the salt generated? Looks like it's a random 8-character alphanumeric string. How is the password generated? Is it still: ?Is there a smarter way to go about it than hacking code? If I can make this work acceptably, I'll make the code available. Seeing as it'll most likely be in Python, I'll link it from this thread. RE: Bulk import users by writing directly to users table - dragonexpert - 2017-01-11 I'd recommend using the user datahandler class for this because it makes sure to populate all tables that are needed. Look at /inc/datahandlers/user.php. RE: Bulk import users by writing directly to users table - strix - 2017-01-11 (2017-01-11, 03:11 AM)dragonexpert Wrote: I'd recommend using the user datahandler class for this because it makes sure to populate all tables that are needed. Look at /inc/datahandlers/user.php. That would seem to be the sanest option, thanks for the pointer (and I can see the sanity checks in UserDataHandler). Is there any web-based documentation on the core functions and classes, similar to WordPress's codex, or is it a case of "the code is the documentation"? And if I have any trouble on the PHP end of things, should I post here or to the dev's forum? Thanks, s. RE: Bulk import users by writing directly to users table - dragonexpert - 2017-01-11 There is some documentation on the site here under Docs, but most of it is by looking through code. I have some plugin techniques here: https://github.com/dragonexpert/tutorials/blob/master/advanced_plugin_development.html Any issues with this I'd say should go to Plugin Development. RE: Bulk import users by writing directly to users table - strix - 2017-01-11 (2017-01-11, 04:05 PM)dragonexpert Wrote: Any issues with this I'd say should go to Plugin Development. Thanks for the tips and for the direction. I'll mark this thread as resolved, and then post my solution once it's completed. Cheers! Here's my first attempt at a CSV user importer. It's command-line only, sorry, because that's all I need. Plus, as you will see, it is quite simple. Because it's so short, I'm pasting the code here. If admins prefer, I can host it on my server and link it. I assume anybody who knows how to use a shell will know what to do with this. Perhaps someone who does UI stuff might turn this into a proper MyBB plugin. CAUTION:
|