This thread will detail how to have a single login for multiple forums. It makes the following assumptions:
A valid vbulletin license exists for each install
All forums will be on the same server
You already have one forum operational AND that forum uses a BLANK $tableprefix!
One database will contain all the tables
This thread is a follow-up from this discussion over at vbulletin.com. Thanks to Brains for some pointers!
Here are the steps:
Copy your forum directories to a parallel directory (for example copy /www/forums to /www/new_forums)
In /includes/config.php, change $tableprefix (line 91) to a new prefix [for example $tableprefix = 'new_';]
Run the vb install from the new directory (/www/new_forums/install/install.php)
During the install, be sure NOT to empty the tables. If you have any doubt about what this means, stop NOW! If you empty the tables, you will lose all of your existing data from a prior install!
Download the files from these directories to your PC: /new_forums, /new_forums/admincp, /new_forums/archive, /new_forums/includes, /new_forums/modcp, /new_forums/subscriptions
We are now going to make global changes to the files in the folders (and subfolders) above. I used Dreamweaver's "edit-find and replace" function with "find in" set to "Entire Current Local Site". We are basically going to remove the "TABLE_PREFIX" from any code dealing with the user. (Note - if you are comfortable with unix command, you could do these changes from the command line on the server.)
Run the following find and replace operations:
Find [" . TABLE_PREFIX . "user] (find what's inside the brackets). Replace with [?.?user] This should find 562 instances of user, usergroup, userfield, and usertextfield
Find [" . TABLE_PREFIX . "strikes] (find what's inside the brackets). Replace with [?.?strikes] This should find 5 instances of strikes
Find [" . TABLE_PREFIX . "pm] (find what's inside the brackets). Replace with [?.?pm] This should find 61 instances of pm, pmtext, pmtextid, and pmreceipt.
Upload these directories back to the server.
We now need to do a little fine tuning
In /includes/functions.php: on line 1171 remove the table_prefix before $idname.
In /includes/adminfunctions: modify print_choser_row (line 1161)to check for $tableid of user, usergroups
PHP Code:
if ($tableid == "user" OR $tableid == "usergroup") {
$result = $DB_site->query("SELECT title, $tableid FROM "."$tablename$wherecondition ORDER BY title");
} else {
$result = $DB_site->query("SELECT title, $tableid FROM " . TABLE_PREFIX . "$tablename$wherecondition ORDER BY title"); // existing code
}
In /includes/adminfunctions_user.php around line 116 (construct_style_chooser)
PHP Code:
$tableid = $tablename . "id";
if ($tablename == "user" OR $tablename == "usergroupid") {
$result = $DB_site->query("
SELECT title, $tableid FROM "."$tablename WHERE userselect = 1
ORDER BY title
");
} else {
// existing code
$result = $DB_site->query("
SELECT title, $tableid FROM " . TABLE_PREFIX . "$tablename WHERE userselect = 1
ORDER BY title
");
}
Done! Both forums are now accessed by the same user table! PM's are unified across forums as is the user count.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
I know this is a very old thread, but I am still running 3.0.xx and I need to build a second site which will use the user tables of my first one, so here I am.
I would like to know how the "sessions" are handled. I have some questions here and I would appreciate if someone can answer them for me.
Let's assume two sites, A and B. With this hack, all user information is kept in the "user" table in database A.
A member of site A logs in Site B. Obviously, since the last login time is stored in the shared user table, the last login time entered in the table, will be common for both sites, correct? So if the member comes back after two days and logs in site A, the last login time will be the last login time from his visit in site B. That means that if the user asks to see the new posts since his last visit (for example), the posts shown to him will not be correct, he will miss the posts between the last time he visited site A and the time he visited site B. Am I correct on this? It is of course possible to alter the user table to have separate columns for these time parameters for site A and site B.
Another question: again, let's suppose that a member logs in site B, does some work there and then follows a link to site A. Will he still be logged in in site A or will he need to re-log in in the other site? In other words, how are cookies handled? And what difference will it make if someone uses the "Remember me" checkbox in one site?
Finally a code question: the author suggests that we use a new table prefix for the new database "new_". The changes suggested show an empty table prefix though, for the old database. Shall I assume that wherever it is suggested to replace " . TABLE_PREFIX . " with ".", if one uses a prefix in the old database, he should replace " . TABLE_PREFIX . " with whatever his old table prefix is? I guess one could define something like "USER_TABLE_PREFIX" with the value of the table prefix used in the first site, and do the find and replace operations you suggest?
Again, I am aware this is an old hack, which has already been ported to later vB releases, but since I do not plan to use later releases, and this thing is pressing me, I would certainly appreciate any help you can give me.