MyBB Community Forums

Full Version: Change User Table Prefix [LF info, not full code]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys/girls!

I asked this question in the support board, but the guys over there referred me to this board.

I'm just wondering where abouts I could find where MyBB defines the tables to use, so that I can change the prefix for the user table.

not looking for full code (just yet), I want to try do it myself first Smile
And um, how does MyBB define it's prefixes? (is it declared by a single function, multiple functions, constantly used variables, etc etc?

Thanks in advance Smile
It's a single define, TABLE_PREFIX, you will actually have to change all occurences where users table is used at all, with or without TABLE_PREFIX, e.g. functions like $db->write_query("users", too.

You can do some of these with a simple search & replace (grep -Enr '"users\>' hits 352 occurences, not counting install/upgrade routines), however there may be more than those, also all plugins you are using may require the same change.

And that search & replace will only work if you actually keep the prefix and only rename users to something else. So if your ultimate goal is to have two MyBB that share the same users table, one of them would need to have the prefix "foo", the other "foobar", and in the "foo" MyBB you replace "user" with "baruser" so both will actually be using "foobaruser".

And no I have no idea if that'd actually work. Or more accurate, even if you manage two MyBB to use the same users table, it won't work, or have wrong data, since data like PMs, lastpost, etc which is all held in the users table, will be wrong for one or the other forum.
I believe TABLE_PREFIX is defined in inc/config.php
Yep you could add your own hook in db functions and catch when "users" table is queried but it isn't only this, you'll have to patch other MyBB's areas to handle it properly as frostschutz said.
didn't realize it was sick a big job. Found a punbb edit to do it, and it was one thing >< oh well, I like mybb so I'll see what I can do. If I go through with this, and get it to work, I'll release the files for the MyBB community to use (if the developers don't mind)

Also, you're a Linux user, frost? What distro?