Page 3 of 4

Re: Users Sharing or Synchronisation between multiple sites

Posted: Fri May 28, 2010 12:48 pm
by headghogg
Hi Guys

Not sure if this is hijacking and if so I apologise but my query is exactly like the title.

All I want to do is sync loads of different sites' users to one site but only one way. So I have 1 site with all users and lots of sites which have their own users.

Running a cron job at night for each site to update the central site maybe.

The central site will be a forum for everyone and i want to avoid people having to register twice.

Any help would be great.

Mark

Re: Users Sharing or Synchronisation between multiple sites

Posted: Mon Dec 20, 2010 9:23 am
by bonzo_bcn
I am testing this hack, but I'm facing a problem: there can't be two admins logged on the backend of the different sites at the same time.

If one admin logs in, the other site admin is logged out automatically.

I've set up the same $secret in both. Any ideas? At this time I'm only sharing VM tables.

EDITED: I shared the user tables of the first post and everything is working like charm.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Tue Dec 21, 2010 5:14 pm
by Per Yngve Berg
Do both admins have their own users?

Re: Users Sharing or Synchronisation between multiple sites

Posted: Tue Dec 21, 2010 5:29 pm
by bonzo_bcn
No, same users for both

Re: Users Sharing or Synchronisation between multiple sites

Posted: Tue Dec 21, 2010 5:33 pm
by Per Yngve Berg
Create a separate user for each person.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Fri Feb 18, 2011 11:27 am
by SAGV
Hallo, what can I do if command "Create View" isn't allowed on my server? I found that I just can write something like

Code: Select all

$sql = str_replace( '#__users', 'jos_users', $sql );
for tables in database.php but this code is for joomla 1.0. It doesn't work with 1.5.
What should I write for joomla 1.5?
Are there any other ways to share users and sessions?

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sun Feb 20, 2011 2:13 pm
by SAGV
Could anybody help me?

Re: Users Sharing or Synchronisation between multiple sites

Posted: Fri May 27, 2011 8:03 am
by andmus
Hi, thanks for the great tutorial! i would have a question: you said the this is not a good solution for two existing sites; i understood the i would lose users in one of the two databases but why one them could crash?
Thanks a lot,
Andrea

Re: Users Sharing or Synchronisation between multiple sites

Posted: Tue May 31, 2011 6:10 am
by birnik
Because you will be simply removing the whole tables in respect to users.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Wed Jun 01, 2011 10:31 pm
by Michel Kant
Okay, I have tested the rules (drop tables and created a view) in Joomla 1.6.3.

Respect for the inventor of this rule. :D
It works like a charm.

My new Joomla site very slow. I think because I use to many components.
My old site, still running, is on vbulletin and I want to migrate everything to Joomla.
So I purchased all components I used in vbulletin for Joomla. A blog, gallery, reviews, forums, real estate component, community builder etc.
The migration was going very fast and all content is transferred. Users are able to login so this was done well.
Only, the Joomla site is very, very slow.

I activate GZip and this saves some time. But still.
I read in the forums if there are too many components installed in Joomla, everything is slowing down.
My forum, this contains the most content, and is the most important thing on my site, was very slow.
So I created a fresh Joomla installation into a sub directory only for the forum. And now the forum is quite fast.
The rest of the site is still slow.
My hosting provider is on plesk. And plesk do not allow the same username for 2 different databases.
I created 2 subdirectories with test installations of Joomla 1.6. Both in same database, only different prefix. Jos_ and tst_
I drop the tables, and created view rules. And this works.

Now the question. If I split up my site in more Joomla installations, each with its own db-prefix and install some components in each installation. But all in the same database. will this improve the performance on the site? Or is it better to create more different databases with in mind that users can’t be shared.
Let me try to explain, the site is slow because too many components use to much recourses or is the mysql database to slow for all these components. Or are there too many files if there are too many components.

I hope someone can give me some wise answers.

Thank you

Re: Users Sharing or Synchronisation between multiple sites

Posted: Fri Jun 03, 2011 8:59 am
by Michel Kant
I merged the two different databases to one. Both with its own db-prefix.
And now it works perfect.
The Joomla with Kunena forum db-prefix forum_ and the other jos_
For the user tables, community builder tables and uddeim tables I created a view in the forum_ tables. They look at the jos_ database. And this works perfect. :D

Now I am trying to put symbolic links so I can store all images in one Joomla installation.

Still one question. I have create a forum tab in community builder.
When I clink on a user in the forums, and click on his forum tab, I can see the posts of this user.
But when I’m in the other installation, and click on a user, I see the forum tab. But when I click it there are no posts. The message is "there is no forum installed."
Well. The forum is installed in the other installation. Is there a way to view the forum posts?
tnx

Re: Users Sharing or Synchronisation between multiple sites

Posted: Tue Jun 07, 2011 1:29 pm
by andmus
Hi all,
if i have two existing sites, let's say site1 and site2, and i want to apply the hack above to share users and session, could i update user tables in site1 (copying users in site2) so that i wouldn't lose the users in site2 and after that apply the hack (drop tables in site2 and create views)? Could it works? Could i avoid any crash in this way?
Thanks,
Andrea

Re: Users Sharing or Synchronisation between multiple sites

Posted: Tue Jun 07, 2011 1:59 pm
by Michel Kant
Hi andmus,

Sharing users is easy with this rule. Only, at least one site has to be empty. So no content.
If each site contains content it is not possible.
Let me explain.
User (x) have written some articles on site a, and user (y) have written some articles on site b but both could have the same user id. Here the problem starts when transfering users from one to the other DB. In this case you should create a unique user id for each user, and connect the content.

Lots of work...

If one site is empty, and only contains users, you could modify the sql file and give users a unique user id before adding them to the other DB.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Tue Jun 07, 2011 4:08 pm
by andmus
unfortunately i have already applied the hack to my 2 installations. but in site2 there were only two users. so now the 2 users are in both sites but they have different ids from the originals. if i understood i could connect the contents in site2 with the right ids. is it correct? on the other hand these two users haven't created contents in site1. is it possible to restore a stable configuration??
Thanks a lot.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Tue Jun 07, 2011 4:42 pm
by Michel Kant
Do you have access to phpmyadmin?

Re: Users Sharing or Synchronisation between multiple sites

Posted: Tue Jun 07, 2011 5:01 pm
by Michel Kant
You could try to export the entire DB to a sql file, and edit the user id’s to the right one.
This can be done with notepad++. I use ms excel for editing databases.
if it’s lots of content, it could be lots of work. Only, you said there were only 2 users on one site, so if you can filter the tables, it is a find and replace job..
In phpmyadmin you also can export to csv file. This you can easily import into excel.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Wed Jun 08, 2011 8:03 am
by andmus
OK! let's sum up:my two original users in site2 now have different id and contents in site2 could not be aligned with their authors. i have exported site2's database in a sql file. Now i should find and replace original user id with new user id in all tables. is it right? My problem now is how to replace the right values? for example if i have to replace user id=70 with user id=71 which tables do i have to consider? which search criteria should i adopt?
Thanks again.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Wed Jun 08, 2011 12:57 pm
by Michel Kant
Basically every table that has a column user_id
If you installed lots of components, you will have many tables.
Only, not all tables contains user_id data.

Maybe you could start finding out what tables has a user_id column

If you want, you can send me the sql file and I will check.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Wed Jun 08, 2011 2:05 pm
by andmus
Ok! i think i solved it! thanks again! but i have a doubt now: what does it happen if i delete an user (from joomla backend) who has written some contents? there would be some contents which reference non existing users. is it right? does joomla manage these circumstances? i think so and i could ignore contents written by users who are not in site1. is it wrong?
Thanks all,
Andrea

Re: Users Sharing or Synchronisation between multiple sites

Posted: Wed Jun 08, 2011 4:33 pm
by Michel Kant
Good question. I think the article still will be there. Only, there is no longer a user attached to it. I did not test this before.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sat Sep 17, 2011 7:55 pm
by thomas777
Hi

I am trying to setup multiple Joomla sites with Joomla 1.7 and would like to setup user sync between the sites just as this thread indicates.

My question is does this work with Joomla 1.7.

I followed the instructions but Joomla 1.7 only has 2 of the tables listed in the instructions. Unless I am missing something. The ones that it has is, jos_users and jos_session .

I seem to be able to login on one site and be logged in the other, automatically after doing the views onto the first 2 tables, which is good.

But I want to make sure that everything is correct since the other 6 tables can't be done. Do I need to do more but with different tables.

I don't need this for community builder or anything, just plain Joomla user sync. I wan't users registered on one site to be registered on the other site.

Thanks


birnik wrote:tboheeren asked me, how I done it. I can't send personal messages yet, therefore I reply here. Hope he will read it.

As I managed to make two sites work with common user base, I decided to share how it should be done step by step.

What is the solution?
  • Allows two or more Joomla! sites to have one and the same user base and sessions.
  • It could be used for other stuff (i.e. banners, sections etc.) however this is not subject of this guide. We will review only users and sessions.
What the solution is not?
  • It is not a bridge, a component, module, plugin or something like this. This is a solution on database level.
  • If you want to share components, articles etc. it is much more complicated, however not impossible. But this is not something we will review here.
  • It is not recommended to use this solution for two already existing sites, as at least one of them will either crash, or you will at least lose its user base.
  • The users in the two (or more) sites will have one and the same access rights (i.e. super admin in one will be super admin in the others as well and so on, you cannot set different rights for the different sites).
Requirements:
  • MySQL 5
  • PHP 5
  • Joomla! 1.5
  • The sites should share one and the same database server and the database user should have access rights to all databases in use.
BEFORE DOING ANYTHING TO YOUR EXISTING WEB SITES, MAKE A BACKUP, AS YOU MAY LOSE DATA.

Step by step:
  • Install Joomla! on localhost/site1 (or domain.com - doesn't matter) with database name site1.
  • Install second Joomla! on localhost/site2 (or any domain) with database name site2 - it is important that the database user for both sites is one and the same.
  • Open the configuration.php files of both installations and copy the secret value ($secret = 'somesymbolshere';) from the configuration of site1 to the configuration to site2. So both installations should have one and the same secret key in their configuration. If you want to add even more sites, the other sites should also have the same key for secret.
  • Open phpMyAdmin of the database of site2 and execute one by one (each row is one execution) the following:

Code: Select all

DROP TABLE `jos_users`     
DROP TABLE `jos_session`
DROP TABLE `jos_stats_agents`
DROP TABLE `jos_core_acl_aro`
DROP TABLE `jos_core_acl_aro_groups`
DROP TABLE `jos_core_acl_aro_map`
DROP TABLE `jos_core_acl_sections`
DROP TABLE `jos_core_acl_groups_aro_map` 
Now run the following SQL queries in the same database (if necessary replace site1 with the corresponding database name used by site1)

Code: Select all

CREATE VIEW jos_users AS SELECT * FROM site1.jos_users
CREATE VIEW jos_session AS SELECT * FROM site1.jos_session
CREATE VIEW jos_stats_agents AS SELECT * FROM site1.jos_stats_agents
CREATE VIEW jos_core_acl_aro AS SELECT * FROM site1.jos_core_acl_aro
CREATE VIEW jos_core_acl_aro_groups AS SELECT * FROM site1.jos_core_acl_aro_groups
CREATE VIEW jos_core_acl_aro_map AS SELECT * FROM site1.jos_core_acl_aro_map
CREATE VIEW jos_core_acl_aro_sections AS SELECT * FROM site1.jos_core_acl_aro_sections
CREATE VIEW jos_core_acl_groups_aro_map AS SELECT * FROM site1.jos_core_acl_groups_aro_map
And that is all. Both sites will now have one and the same users and sessions. Adding more sites is easy, just follow the instructions here for site2 database and configuration file.
If you have existing site and you want the new one you are setting up to have all of the users of the old one, you can do it, by just imaging that your old site is site1 in this example and follow the instructions post installation.

If you have two existing sites - THIS IS NOT THE RIGHT SOLUTION FOR YOU.

Updating Joomla?
As for versions 1.5 - there is no problem. Upgrade both of your installations without any worries.
As for version 1.6 - it is hard to say yet, as it is not stable enough.

Hope you find it useful. If you have any questions, ask in that thread.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sat Oct 08, 2011 7:34 pm
by topcafirms
birnik wrote:tboheeren asked me, how I done it. I can't send personal messages yet, therefore I reply here. Hope he will read it.

As I managed to make two sites work with common user base, I decided to share how it should be done step by step.

What is the solution?
  • Allows two or more Joomla! sites to have one and the same user base and sessions.
  • It could be used for other stuff (i.e. banners, sections etc.) however this is not subject of this guide. We will review only users and sessions.
What the solution is not?
  • It is not a bridge, a component, module, plugin or something like this. This is a solution on database level.
  • If you want to share components, articles etc. it is much more complicated, however not impossible. But this is not something we will review here.
  • It is not recommended to use this solution for two already existing sites, as at least one of them will either crash, or you will at least lose its user base.
  • The users in the two (or more) sites will have one and the same access rights (i.e. super admin in one will be super admin in the others as well and so on, you cannot set different rights for the different sites).
Requirements:
  • MySQL 5
  • PHP 5
  • Joomla! 1.5
  • The sites should share one and the same database server and the database user should have access rights to all databases in use.
BEFORE DOING ANYTHING TO YOUR EXISTING WEB SITES, MAKE A BACKUP, AS YOU MAY LOSE DATA.

Step by step:
  • Install Joomla! on localhost/site1 (or domain.com - doesn't matter) with database name site1.
  • Install second Joomla! on localhost/site2 (or any domain) with database name site2 - it is important that the database user for both sites is one and the same.
  • Open the configuration.php files of both installations and copy the secret value ($secret = 'somesymbolshere';) from the configuration of site1 to the configuration to site2. So both installations should have one and the same secret key in their configuration. If you want to add even more sites, the other sites should also have the same key for secret.
  • Open phpMyAdmin of the database of site2 and execute one by one (each row is one execution) the following:

Code: Select all

DROP TABLE `jos_users`     
DROP TABLE `jos_session`
DROP TABLE `jos_stats_agents`
DROP TABLE `jos_core_acl_aro`
DROP TABLE `jos_core_acl_aro_groups`
DROP TABLE `jos_core_acl_aro_map`
DROP TABLE `jos_core_acl_sections`
DROP TABLE `jos_core_acl_groups_aro_map` 
Now run the following SQL queries in the same database (if necessary replace site1 with the corresponding database name used by site1)

Code: Select all

CREATE VIEW jos_users AS SELECT * FROM site1.jos_users
CREATE VIEW jos_session AS SELECT * FROM site1.jos_session
CREATE VIEW jos_stats_agents AS SELECT * FROM site1.jos_stats_agents
CREATE VIEW jos_core_acl_aro AS SELECT * FROM site1.jos_core_acl_aro
CREATE VIEW jos_core_acl_aro_groups AS SELECT * FROM site1.jos_core_acl_aro_groups
CREATE VIEW jos_core_acl_aro_map AS SELECT * FROM site1.jos_core_acl_aro_map
CREATE VIEW jos_core_acl_aro_sections AS SELECT * FROM site1.jos_core_acl_aro_sections
CREATE VIEW jos_core_acl_groups_aro_map AS SELECT * FROM site1.jos_core_acl_groups_aro_map
And that is all. Both sites will now have one and the same users and sessions. Adding more sites is easy, just follow the instructions here for site2 database and configuration file.
If you have existing site and you want the new one you are setting up to have all of the users of the old one, you can do it, by just imaging that your old site is site1 in this example and follow the instructions post installation.

If you have two existing sites - THIS IS NOT THE RIGHT SOLUTION FOR YOU.

Updating Joomla?
As for versions 1.5 - there is no problem. Upgrade both of your installations without any worries.
As for version 1.6 - it is hard to say yet, as it is not stable enough.

Hope you find it useful. If you have any questions, ask in that thread.

I am purely a non-technical person without having any formal education of any coding...I was able to implement this on our website www.topcafirms.com and www.community.topcafirms.com & www.taks.topcafirms.com....... Thanks for gr8 help and clear instruction......... BUT I have one problem...it is not taking care as "single sign" on for all these three setup. What should be done to ensure that person loggedin in topcafirms.com reamined logged in community.topcafirms.com

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sat Oct 08, 2011 9:37 pm
by Michel Kant
I had the same problem. Did you edit all config files? Secret value?

And, do you have cache enabled?

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sun Oct 09, 2011 4:49 am
by topcafirms
i have done all the steps mentioned there...and user has successfully been syncing. Not sure about...cache...can u pls explain what should be status cache in all sites and where to change it. One more doubt, i have linked these website thru 'external link' in main menu..is there any other way to connect. Thnx in advance

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sun Oct 09, 2011 7:39 am
by Michel Kant
I can imagine if sitecache is enabled on one site and disabled on other site, the user needs to login again if he switch sites.
I think there is no other way to link to the other site by using an external url link type. I do the same and I have no problems with that.
Are you using some components like Joomsocial or Communitybuilder?

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sun Oct 09, 2011 9:14 am
by topcafirms
currently all my website cache is disabled...i had enabled on all website and tried checking this but same was not working...shld i keep yes for sometime and check...yes..community.topcafirms.com is on CB only

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sun Oct 09, 2011 9:40 am
by Michel Kant
Maybe there is a problem using CB in one installation only.
My website is on CB also. And I have installed CB on both platforms.
And I did run the table view rule on CB sql tables also.

CB overrule the system login and system registration of Joomla. (if you selected this option).
I can imagine this could result in some problems.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sun Oct 09, 2011 11:46 am
by thomas777
You may know more about this than me, but I think that Single Sign On using this method only works if the website is a sub directory websites. I am not sure about sub domains.

I am about to use the above method with CB also tables viewed aswell. I am hoping if all the websites have the CB login module that all should be ok.

Would this not work, if not what can be done.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Sun Oct 09, 2011 4:00 pm
by Michel Kant
It works on subdomain also.
Just tested this.

Re: Users Sharing or Synchronisation between multiple sites

Posted: Wed Mar 21, 2012 2:48 am
by columbusgeek
This post is probably deader than a doornail, but it's the only relevant discussion about this method so here goes.

I setup this method and it, "mostly" works. If you register on the main site, all is well. If you register on the slave sites then you get a error.
"E_NOLOGIN_ACCESS"

Upon further snooping, I can't seem to pin down what the main site is doing that the slave sites are not doing. Even weirder, I use "theartofuser" extension and I can see the new user in there, but not in joomla's default user tool.

Totally stumped.