Someone asked me how to setup 2 different SMF forums with shared user database. So, instead of writing in private message, I decide to share it here. Besides, I have never tried this myself, so I could use the feedback in case the steps I outline below are wrong or incomplete.
In the tutorial below, the following database tables will be shared:
- im_recipients
- instant_messages
- membergroups
- members
You can share more tables if you like, and if you know what you're doing.
Here it goes...
1. Installing the forumsInstall two (or more) different SMF forum in
the same database, but using different prefix. For this example, the first forum is using "
smf1_" (
without quotes) and the second is using "
smf2_". Just install the two forums normally, don't start telling users to sign up yet.
2. Modifying the source codeOpen each of the .php files located in the Sources directory in your hard drive using a text editor program. Find all occurances of "
{$db_prefix}members" and replace with "
smf1_members" (
without quotes). Do this for every single .php file in the Sources directory. Also find and replace the following:
"
{$db_prefix}im_recipients" => "
smf1_im_recipients"
"
{$db_prefix}instant_messages" => "
smf1_instant_messages"
"
{$db_prefix}membergroups" => "
smf1_membergroups"
You can also share more tables if you want and know what you're doing.
If you have a text editor program that can do batch replace or replace in all opened documents, use that instead, it will ease the task a lot (you can open everything at do a replace for all of the opened files). One text editor program that I know can do this is
JCreator.
3. Upload the modified source filesUpload the content of the Sources directory that you just modified above to the Sources directory in your forum(s), overwrite any existing files. You don't need to do this for your first forum (smf1_), but doing this won't cause any problems.
Your forums should now share the same member, membergroup and instant message database.
4. Optional settingsIf both (or all) of the forums are hosted on the same site (domain), you can use the same Cookie name for SMF, so users won't need to login twice when moving from one forum to another. You can find this setting inside the Admin Center -> Edit Server Settings -> Cookie Name
Possible Issues- User uploaded avatar
Temporary solution: disable this feature.
Better solution: also share the "attachments" table and synchronize the attachment settings (Admin Center -> Edit Features and Options -> Attachments section). This probably won't work if the forums are in different domains or subdomains.
- Forum with multiple themes (ID_THEME conflict in members table)
Temporary solution: use the same themes, or set the default forum theme for all of the forum using the same ID, and don't let users select their own theme. - Show unread may not work when moving from one forum to another
You should edit in the templates and replace the link to "action=unread" to "action=unread;all;start=0". What this does is show all unread posts by that user.
Other recommended tables to share:
- log_karma
- log_online <- session might get screwed if the forums are in different domains
Any comments/suggestions/errors?
I keep on thinking I'm forgetting something here...