WordPress subdomain and multiple sites

I have a wordpress website say www. flowers.com .
Now can i have 3 subdomain called “Roses” , “sunflower” , “orchids” with a fresh wp install eg: www. roses.flower.com , and main website got links pointing each sub dir index file. And they all working fine

Now how do one user log in all sites with one user name ?

Read More

I tried using same sql directory database on all subdomain sites, but still each and every time the user need to login for different subdomains .

all ideas are welcome .

thanks in advance 🙂

Related posts

Leave a Reply

2 comments

  1. 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.
    enter image description here

    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.