MyBB Community Forums

Full Version: Triggers and/or views on mybb users to share them between databases [UPDATE]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everyone! Guess what! I got a new way for you guys to connect all users from one mybb forum to another! How much work does it take?! 15 seconds! I'll post my findings soon! If your wondering how to do it, it is very simple... You use an SQL View, like I suggested in my 2nd proposal. I will post a tutorial on the subject... and I may develop a plugin also.


I've been searching for a way to have multiple mybbs running on the same user table... I have yet to find a good way to do this, does any one know of one?

What do you think of this proposal:
1: create a trigger to update one user table when a user is registered on another?

OR

2: install both mybbs on one database and maybe create a view of the user table for one database and name it as the table for the other mybb instant.
Here is an article which discusses something similar:
Using views to reduce number of tables used


OR



3: Create a plugin that hooks into user registration and have it create another user on the other forum.


So what do you guys think? I'd love to do it the number 2 way...
Welcome to MyBB MrLeet / You're interested in one of my favorite topics.

One option = Here this works for me...
[Tutorial] Sync your users with another MyBB board

It's not difficult, the "hardest part" is dealing with details like redirecting your registration and password updates (various links) to the master forum.

#
Another option = Triggers
Sure it can be done; I don't have a step-by-step tutorial for that one yet.

Have fun Smile
(2011-03-19, 08:15 PM)seeker Wrote: [ -> ]Welcome to MyBB MrLeet / You're interested in one of my favorite topics.

One option = Here this works for me...
[Tutorial] Sync your users with another MyBB board

It's not difficult, the "hardest part" is dealing with details like redirecting your registration and password updates (various links) to the master forum.

#
Another option = Triggers
Sure it can be done; I don't have a step-by-step tutorial for that one yet.

Have fun Smile

Thanks for replying, I saw your method and I didn't like it because of the same points that pavemen points out in the thread. What do you think about my 2nd option? I feel if its practical (Haven't used triggers or views since my course work) then it would be a perfect implementation.
Its a shame that mybb does not allow custom tables like wordpress and bbpress Sad. I'm on spring break and I have some time here and there to do testings... I'll see what I come up with Shy. Worst comes I can always make a hack job plugin for people to get ideas from.

Edit I got it to work with views Big Grin
(2011-03-19, 10:06 PM)MrLeet Wrote: [ -> ]I got it to work with views Big Grin

Nice, what about data like last post? (for example)
or more importantly password updates? (updates originated on the 'slave' db)
Are you updating both the view and the original DB?
How?

#
Re: Paveman's comments
His main point was that updates (in my example) take 20 minutes.
I chose that to insure low server load. You could update every minute if you want.


(2011-03-19, 10:47 PM)seeker Wrote: [ -> ]
(2011-03-19, 10:06 PM)MrLeet Wrote: [ -> ]I got it to work with views Big Grin

Nice, what about data like last post? (for example)
or more importantly password updates? (updates originated on the 'slave' db)
Are you updating both the view and the original DB?
How?

#
Re: Paveman's comments
His main point was that updates (in my example) take 20 minutes.
I chose that to insure low server load you could update every minute if you want.
last Post? Not sure. I've only been using mybb for like 2 weeks so I don't know where that would be located... If the column where that data is stored is not in the user table it will not show up on both forums. Currently only the user table is shared between the forums, so anything in the user table is the same on the two forums. However, things like "newest users" and user count are different as that particular member registered on a certain forum and not both so only one forums proper tables were updated (besides the user table). The member list on the other hand shows members from both forums lol.

Also, you asked if the other table is updated when the view gets updated, yes it does.Big Grin

EDIT: proper updates? Everything is updated on the real table. You can place triggers on the view however to update other tables or prevent things from not being updated if need be.
Sounds like you are having fun, good job. Smile

FYI:
There is a last post column in the user table (re: the users most recent post), that was just an example. Password and email updates are obviously much more important.

Enjoy
Don't wanna dig up old graves here,
But after reading almost a dozen threads about people asking how to merge/sync/share the usertable/userdb

What's the best and easiest way to let 2 or more installations of MyBB share only a username and password. So if you log in on forum A you can also log into forum B, (only username/pw not posts/sig/group/etc)

Don't mind me asking, since there is never been given a answer that solves that solved the questions.
hmm this isn't really a hard thing to do. Another way that I was doing this was with a simple plugin. I did the same for Joomla user integration. The biggest issue was just password hashing between the two but that was an easy fix too.

Essentially all you need to do is write a plugin that triggers on registration (do_signup I think)

All it needs to do is store all of that information in something like an XML file or use an http tunnel or simple REST to go an create the data.

An even easier way to do it would be through database mirroring for the users table.

But I was easily able to integrate all the users I wanted from several systems, all it did was when on the same server, connect to the other database and then create the user directly in there, when using mybb you can easily use the mybb functions and classes to do this, just with a different DB connection.

Another way I managed it on a remote server was to simply create an XML document (well hidden) that was picked up every 30 minutes, the server that retrieved it checked if the users existed, via username or email, failed if either existed, and then inserted the user

Every server had a cron for the other servers so they all synced up hourly. You need to make sure that you destroy the XML file after it has been processed as well, otherwise you will leave the opportunity for people to find the XML with all the passwords, although hashed, still there.

A simple way to do this was to create a "processed" file on each server once things were processed then at the very end of processing each server grabs the processed from the other servers and destroys all the content that was processed.

Sounds more longwinded than it is, the entire round robin process took less than an hour to code and implement