Solution:
Our goal is to set up two WordPress websites which will share logins and the same users. Once a user has subscribed one
website, she would be able to access the other website with the same role and capabilities.
step 1: In order to share the same users and usermeta tables, WordPress installations must share the same database. add prefix of first wordpress installation first_ and second wordpress installation table second_. in same database.
step 2: When the first WordPress website is up and running, we can edit its configuration file. Open /first/wp-config.php
and add the following lines above the ‘stop editing’ comment:
$table_prefix = 'first_';
define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
// custom users and usermeta tables
define( 'CUSTOM_USER_TABLE', $table_prefix . 'users' );
define( 'CUSTOM_USER_META_TABLE', $table_prefix . 'usermeta' );
/* That's all, stop editing! Happy blogging. */
step 3: We are done with the first installation. Next we have to copy wp-config.php from the first installation folder and
paste it into the root folder of the second installation. Be careful to change the $table_prefix value accordingly:
open /second/wp-config.php.and add the following lines above the ‘stop editing’ comment:
$table_prefix = 'second_';
define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
// custom users and usermeta tables
define( 'CUSTOM_USER_TABLE', 'first_users' );
define( 'CUSTOM_USER_META_TABLE', 'first_usermeta' );
step 4: write in both wp-config.php for sharing cookies.
//Share cookies
define('COOKIE_DOMAIN', '.xyz.com');
define('COOKIEHASH', 'aee53c017c29dc0d3ae37253fc8cbfd8');
step 5: Open table “first_usermeta” and copy from column meta_key – first_capabilities and first_user_level to the second_capabilities and second_user_level.
step 6: When running the second installation, we should set a non-existent email address for admin user as WordPress finds a number of existing users from first_users table.
For more Detail https://kinsta.com/blog/share-logins-wordpress/.
It’s work for Me.