Wordpress: we can Share users database to create a great use

Einfach Dinge, die nichts mit XAMPP, Apache Friends, Apache, MySQL, PHP und alle dem zu tun haben. Allerlei halt. ;)

Wordpress: we can Share users database to create a great use

Postby unleash_it » 03. January 2020 14:01

hello dear apachefriends, good day dear Apache & Xampp-fans from all over the globe.

in this little "allerleit-forum we share the ideas about best practice in wordpress:
today: How we can share the Users-database in a sysem of multiple WordPress

the great thing is: WordPress gives us the option to set the custom tables instead of only being able in using {$pref}users and {$pref}usermeta.
That said: we see that we can build up a system of two (or let me say even more than two) WordPress websites share which are able to run on one database.

The great ting is: doing it right then we are able to run the same users and usermeta tables for all the sites in the little system of multiple Wordpress-installations.
The benefit here is: all the websites in the little network - they share these (above mentioned) table that hold the same users.


Note: In order to share the same users and usermeta tables, WordPress installations must share the same database.

We just need to do minor changes - in fact only we have to add these two lines:

we have to tweak the define
Code: Select all
CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE into wp-config.php file
, as shown in the following little code-chunk:

see - we can do it like so:
Code: Select all
// custom users and usermeta tables
define( 'CUSTOM_USER_TABLE', 'my_users_table' );
define( 'CUSTOM_USER_META_TABLE', 'my_usermeta_table' );


Well it is just that easy: we only have to change the default WordPress table prefix, - By doing so we have two choice: we can do it during the installation-process which is pretty convenient;- or
we can edit the wp-config.php file where we have to change $table_prefix value.

So thats it: Afterwards - the second website is then been installed, - And now we can do the adding of these two lines in wp-config.php file, just before this line:

we we have to add these two lines:

Code: Select all
define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USERMETA_TABLE', 'wp_usermeta');


Note: we have to make sure you replace “wp_” by the first website table prefix.
With this code we’re asking the second website to use the first website users table. Thats the whole trick

With that were done, now logged users will have their fun while running only one session across the whole little network of wordpress-sites.


in this little "allerleit-forum we share the ideas about best practice in wordpress:
today: How we can share the Users-database in a sysem of multiple WordPress


hope someone might find it useful

if you want to add some ideas - just write -

thanks alot for all you do!!

regards
Interessen: Bikes & steel frames: Linux & SBC https://www.allaboutcircuits.com :: die neuen Knowledge-Base: AFFiNE: There can be more than Notion and Miro. auf affine.pro :: WordPress Entwicklung - sic: make.wordpress.org/core/
User avatar
unleash_it
 
Posts: 779
Joined: 10. December 2011 18:32
Operating System: linux opensuse 12.1

Return to Allerlei

Who is online

Users browsing this forum: No registered users and 29 guests