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.
Anyhow, once you figure out how to do this with 3.5.3, I, and numerous others, will be extremely grateful.
Only question with that is this - will I be able to still "merge" the databases if both forums are already setup, but not large at all?
Thanks!
Under the current setup, merging would be difficult. I'm going to modify the install instructions (eventually :disappointed: ) so that instead of each install being in the same db, they have a different db's with the user's linked view a "shared_prefix" when calling tables.
Has anyone tried doing this with 3.5.x? The concept is identical; there may just be other places where if statements need to be used instead of a straight find and replace.
One of the things I thought I'd see present in this hack would be the ability to show all users logged in from all sites in the form of one big who's online.
For example, if I have 5 users on site 1, and 10 users on site 2, I would be looking at a list of 15 users total.
Why doesn't the who's online feature show all members on both sites? I guess it's because the "session" table is unique on site 1 and site 2. Is this possible to show all logged in users from both active sites?
Would it be a matter of modifying the whos online for the 2nd install to use Site 1's session table? would there be any problems sharing the 'session' table?
There is nothing wrong with any of the instructions. Not only this, but I was able to share the 'sessions' table and now all users are actively shown on both sites.
The good news is it's working.. just like I thought it would.. the bad news is it's way to early to tell if anything will or can go wrong.
Also, since I'm not having a problem, and I'm also on a way older version of VB than described in this hack, just to let you know.... #8 the $idname hack info above for a certain function didn't even exist!
Not only this, my search and replace couldn't find any " . TABLE_PREFIX . "strikes either. When in doubt, the only thing really required is review of your SQL statement. When the author says replace " . TABLE_PREFIX ."user with "."user he really means replace it just like that.
I will mention another thing that puzzled me, if you notice, the author is using some special "quote" around his periods in the tutorial above. In my case, it appeared like block characters in my Search and Replace function so I just replaced the funky `` quotes into single double quotes surrounded by the period. ie: "."
Peter - thanks for explaining some of the above. Yes, this is for vb3.0.x. The concept is the same for vb 3.5.x but you will need to make changes, especially for #8. I keep saying I intend to update this but between RL, helping with ecDownloads, finishing up a new extension I'm about to release ... not enough time in the day!