Imagine that we are in this situation:
We have a collaborative website (wiki type) multi-language , each language is in a subdomain, each of these subdomains has its portal made with WordPress, its forums with bbPress and its wikis with MediaWiki, an extra to share the files (like the Wikimedia Commons) and we want users and cookies be unified, integrated.
Okay, it seems a bit far fetched, but it's possible. But I notice that this article is quite extensive and maybe heavy.
So, with what we have seen, we are going to integrate the following:
Of course, the amount may be greater, but I explain it this way because it is what I use.
This tutorial also helps if you do not want to integrate with MediaWiki, so you can leave it early
To start, do the two installations of WordPress ((Better that they are in the same database, to make things easier and because I have not found any way to do it with different databases)).
Very important : For the integration of cookies to work correctly, especially in the integration with bbPress, the facilities should be in different subdomains but with identical directory names.
You need to add the " Authentication unique keys "((For security and to improve integration)). Make them equal between blogs, not between them, and then get to unify cookies. This is quite important. The key NONCE_KEY of each installation should be different. You can use the automatic generator that the creators of WordPress put at your disposal.
And I feel heavy, but remember to put the same keys between the blogs, not between them, and put the NONCE_KEY different, for safety.
Once you have done this, decide which of the two installations will be the main one (for example, the one with the prefix " wp1_ ") and the secondary one ( in this case, " wp2_ "). Now, let's edit the file wp-config.php the latter. After the definition of the prefix of the tables, it is necessary to add:
define ( 'CUSTOM_USER_TABLE' 'wp1_users' ) ; // Integration of users
To make things easier, it is not necessary to share the usermeta table, because if you do you must add a few things so as not to lose administrative access to the second blog. The only good thing about joining them is that the name to be shown, if it is different from the user name, will be updated in all the installations. It also helps you, to share it, to have all the user permissions together, but since it is only a visual thing in case you access the BD, better not to touch it ((I have put it together, I admit it.) But it has given me a few problems By the way, I also recommend, once made these changes, follow the tutorial that ejner69 did about Change the name to the user admin to be able to have the username you want.
What is missing now is to integrate the cookies completely. This is something more to understand depending on how you have mounted the shed (subdomains, databases, etc.). I have it so beautiful that it took me three days to get it.
To encrypt the login data, WordPress uses, apart from the keys AUTH_KEY SECURE_AUTH_KEY and LOGGED_IN_KEY other random and unique keys generated during installation calls AUTH_SALT and LOGGED_IN_SALT (and SECURE_AUTH_COOKIE if you use an SSL connection) and that saves them in the database. With this in mind, it seems that it can be difficult to integrate everything, but it is not so. You just have to define them in the wp-config.php of each installation to be the same.
As if you use subdomains within the same domain, the names of the cookies will also be different, because they are put into use of the subdomain, in the end you better do something like this:
* Integrations of cookies
define ( 'COOKIE_DOMAIN' '. domain.tld' ) ; // To serve in all subdomains of the domain
define ( 'COOKIEPATH' '/' ) ;  define ( 'AUTH_SALT' 'loquetuquieras' ) ;
define ( 'LOGGED_IN_SALT' 'otracosadistinta' ) ;
define ( ] 'AUTH_COOKIE' 'nameofweb_numerosyminusculas' ) ;
define ( 'SECURE_AUTH_COOKIE' 'name of the web_sec_numerosyminusculas' ) ; // If you use SSL connection  define ( 'LOGGED_IN_COOKIE' 'nameweb_logged_in_numerosyminusculas' ) ;
define ( 'TEST_COOKIE' 'nombredelaweb_test_cookie' ) ;
Where it says numerosyminusculas put the same thing in three. The most recommendable is, for example, the hash md5 of the domain of your web or the hash md5 of a random sentence ((You can generate those hashes using this online tool )). This is simply to give them a unique name that does not bother the cookies of other websites.
Now you can try and log in to the installation you want and access the other. You will see that the session is also started. Keep in mind that the user's password will be what you have in the installation of the shared table, logically. If you try to close session, you will see that it also closes in both
Here we must pay special attention in the installation if we want to make it easier. For starters, I recommend that you add the translation file that Fernando has made in the folder / bb-includes / languages . Once you've done it, it's as easy as accessing the URL where the forum will be and choosing es_ES from the drop-down list. Then, Let's go to it! .
We fill in the configuration of the database and continue with the installation as if you were not going to integrate WordPress. In this case, you can put the bbPress installations in databases other than WordPress. Even different from each other.
Very important : Within the security codes, you must put the same as in the installation of the WordPress, except the NONCE ]which should be different for security.
Once we get to the page to choose the username, put it the same as the WordPress installation. If you have not changed it, put admin .
And do the same for the second forum. Keep in mind that the cookies will only work if they are in different subdomains but in folders with the same name that I spent a lot of time trying not to, but it is.
Now there's to edit the file bb-config.php of each installation. Add before ?> :
/ * Integration of the database * /
$ bb-> wp_table_prefix = 'wp1_'; // The prefix of one of the two installations of WordPress
$ bb-> user_bbdb_name = 'bd_wordpress'; // Database where the WordPress are
$ bb-> user_bbdb_user = 'user_bd_wordpress'; // User of the database where the WordPress are
$ bb-> user_bbdb_password = 'password_bd_bd'; // Password of the WordPress database
$ bb-> user_bbdb_host = 'host_bd'; // Host of the WordPress database, usually 'localhost'
$ bb-> user_bbdb_charset = 'game_characters'; // The character set of the WordPress database; usually 'utf8'
$ bb-> user_bbdb_collate = ''; // If you do not know what it is, leave it blank
$ bb-> custom_user_table = 'wp1_users'; // The shared table of users
/ * Integration of cookies * /
$ bb-> bb_auth_salt = 'AUTH_SALT'; // Same as in WordPress
$ bb-> bb_logged_in_salt = 'LOGGED_IN_SALT'; // Same as in WordPress
$ bb-> wp_siteurl = 'http: //subdomain.domain.tld/directory-wp'; // URL of access to your WordPress
$ bb-> wp_home = 'http: //subdomain.domain.tld/directory-installation-wp'; // Installation URL of your WordPress
$ bb-> cookiedomain = '.domain.tld';
$ bb-> cookiepath = '/';
$ bb-> authcookie = 'AUTH_COOKIE'; // Same as in WordPress
$ bb-> secure_auth_cookie = 'SECURE_AUTH_COOKIE'; // Same as in WordPress
$ bb-> logged_in_cookie = 'LOGGED_IN_COOKIE'; // Same as in WordPress
$ bb-> admin_cookie_path = '/ directory-bbpress / bb-admin'; // Directory (of the URL) where is 'bb-admin'
$ bb-> core_plugins_cookie_path = '/ directory-bbpress / bb-plugins'; // Directory (of the URL) where is 'bb-plugins'
$ bb-> user_plugins_cookie_path = '/ directory-bbpress / my-plugins'; // Directory (of the URL) where is 'my-plugins'
$ bb-> sitecookiepath = '/ directory-installation-wp /'; // WordPress installation directory (of the URL); this is why it was necessary that they were different subdomains but in directories with the same name
$ bb-> wp_admin_cookie_path = '/ installation-directory-wp / wp-admin'; // Directory (of the URL) where is 'wp-admin'
$ bb-> wp_plugins_cookie_path = '/ install-directory-wp / wp-content / plugins'; // Directory (of the URL) where the WordPress plugins folder is
* End of user integrations
24  25
* User integrations
/ * Integration of the database * /
$ bb -> wp_table_prefix = 'wp1 _' ; // The prefix of one of the two installations of WordPress
$ bb -> user_bbdb_name = 'bd_wordpress' ; // Database where they are WordPress
$ bb -> user_bbdb_user = 'user_bd_wordpress' ; ] // User of the database where the WordPress are
$ bb -> user_bbdb_password =  'password_bd_wordpress' ; // Password of the WordPress database
$ bb -> user_bbdb_host  = 'host_bd' ; // Host of the WordPress database, usually 'localhost'
$ bb  -> user_bbdb_charset = 'game_characters' ; // The character set of the database of the WordPress; usually 'utf8'
$ bb -> user_bbdb_collate = '' ; 19659023] // If you do not know what it is, leave it blank
$ bb -> custom_user_table =  'wp1_users' ; // The shared user table
/ * Integration of cookies * /
$ bb -> bb_auth_salt = 'AUTH_SALT' ; // Same as in WordPress
] $ bb -> bb_logged_in_salt = 'LOGGED_IN_SALT' ; // Same as in the WordPress
$ bb -> wp_siteurl = 'http: //subdomain.domain.tld/directory-wp' ; // URL to access your WordPress
$ bb ->  wp_home = 'http: //subdomain.domain.tld/directory-installation-wp' ; // URL of installation of your WordPress
$ bb -> cookiedomain = '. domain.tld' ;
$ bb -> cookiepath = '/' ;
$ bb -> authcookie = 'AUTH_COOKIE' ; // As in WordPress
$ bb -> secure_auth_cookie = 'SECURE_AUTH_COOKIE'  7]; // Same as in WordPress
$ bb -> logged_in_cookie =  'LOGGED_IN_COOKIE' ; // Same as in WordPress
$ bb -> admin_cookie_path = '/ directory-bbpress / bb-admin' ; // Directory (of the URL) where 'bb-admin' is
$ bb -> core_plugins_cookie_path = '/ directory-bbpress / bb-plugins' ; // Directory ( of the URL) where is 'bb-plugins'
$ bb -> user_plugins_cookie_path = '/ directory-bbpress / my-plugins' ; // Directory (of the URL) where 'my-plugins' is
$ bb  -> sitecookiepath = '/ directory-installation-wp /' ; // Directory (of the URL ) of WordPress installation; this is why it was necessary that they were different subdomains but in directories with the same name
$ bb -> wp_admin_cookie_path = '/ directory-installation-wp / wp-admin' ; // Directory (from the URL) where 'wp-admin' is
$ bb -> wp_plugins_cookie_path = '/ installation-directory-wp / wp-content / plugins' ; 19659023] // Directory (of the URL) where is the WordPress plugins folder
* End of the user integrations