MyBB Community Forums

Full Version: sync two(2) MyBB's users that are on the same server
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys (again),
In the course of time I've used MyBB, I found that it would be easy for me to create two(2) different instances of MyBB on the same site (each in his own sub dir. and each with his own database). This is because: one(1), I want to operate a few special plugins (like @nickman's blog, @Labrocca's contact form and others) without them "messing up" my main database and two(2), the way my ISP's database server is configured, this would give me (some) backup in case my forum will be hacked (again).
Do to that I want a way to sync users between the two(2) databases. The sync should include the username, password, user's email, but not ban or group(s) - they would be a "bit" different on the two(2) forums.

1. Can it be done at all?
2. If it can, how do I do this?


Thank you all,
Ori...
Isn't there a way to do this? Can't someone help me? Please...
I think it is possible but it isn't exactly easy and I don't think anyone has ever done it successfully.
(2009-04-07, 09:15 AM)MattRogowski Wrote: [ -> ]I think it is possible but it isn't exactly easy and I don't think anyone has ever done it successfully.

I've done it before, but not easily - everytime a member updates their profile, or an admin updates the information for example, a function is called to update a different database. I guess it can be changed to update whatever you want - at the minute, I only update username / email / password for a plugin I'm developing...

It does have problems though, so I can safely say it's difficult to accomplish.
OK, I think the way to go (as I said, I need only the username, password, user's email) is using a timed/scheduled task to do a "get" from my main forum's database and a "put" on the secondary one. I know that this will cause a time "lag" between each task run, but (by your posts) this would do the job the easiest.
Not really. Syncing the information when the user updates is the easiest way - with a task, you'll have to queue who has edited their information, then run the task. What if the task isn't run "on-time", and there's a problem - the two sets of data will be mixed.
Tomm, can you tell me what steps to do to find and edit the function you mentioned? As I said, I, also, want to sync, only, username, password and email (everything else I would do manually as there will be, some, differences between the to forums/databases).
You do realise that it's a custom function we made? I don't work there anymore, but I briefly remember what we did...

In ./inc/datahandlers/user.php, there are several hooks that you can use to hijack and make a copy of the information. For example, take a look around line 971:

		$plugins->run_hooks_by_ref("datahandler_user_insert", $this);

		$this->uid = $db->insert_query("users", $this->user_insert_data);

This is where a new user is generated and inserted into the database. You can use this hook to have a function copy this into another database, or simply put another query in next to the one that's already there.

The same can be used again when the user updates their information, but with the other hook - $plugins->run_hooks_by_ref("datahandler_user_update", $this); (around line 1162).
Thanks, I do the work soon. First - hospital and two(2) translations I want/promised. And b.t.w., you were spot on with the line numbers.