• I’ve recently taken over a project including a WP 4.2.5 install in the root folder and a subdirectory install for a different language. Before now both installs have been using separate database tables (wp1_, wp2_).

    I’ve been searching for hours and found a lot of info on cookies, my wp-config settings are:

    Main site

    define('COOKIEPATH', '/');
    define('SITECOOKIEPATH','/');
    define('COOKIEHASH', md5('www.site.co.uk'));

    Sub site

    define('CUSTOM_USER_TABLE', 'site_wp1.wp1_users');
    define('CUSTOM_USER_META_TABLE', 'site_wp1.wp1_usermeta');
    
    define('COOKIEPATH','site.co.uk/');
    define('SITECOOKIEPATH','site.co.uk/');
    define('COOKIEHASH', md5('www.site.co.uk'));

    I had the subsite redirecting to the successful login page but the user doesn’t stay logged in, access is restricted and going back to the login page shows login instead of logout. Still an issue with cookies?

    EDIT
    Strangely, logging in on the main site will work fine, however navigating to the subsite will stay logged in and access is like normal except using the logout button navigates to the logged out page yet keeps the user logged in…

    I can’t access the subsite/wp-admin with these settings, attempting to login just refreshed the page and stays on 2 attempts left, acting as if login worked, but wasn’t registered…

    All the same plugins are used on both installations.

    Anyone know of a solution?
    Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m not sure what you are trying to achieve, or what the problem is.
    Do you want members to be logged in on both sites automatically?
    And what do you consider the successful login page? Is it on the subsite?

    For the record you are posting in the multisite forum, yet multisite doesn’t mean multiple sites with multiple installs, multisite is one install with multiple sites.

    If you want members to be logged in on both sites then multisite + Join My Multisite could be a solution. Yet if you want your site to be multilingual you do not really need multiple sites for this, it could be easier with a plugin like Polylang.

    If you have many pages/posts it could be a lot of work to change that though.

    Either way, you can import the content from one site to the other. When you import to a new site make sure to copy all settings, the theme and plugins first (you may need to do so manually).

    And if you choose multisite, a plugin like Multisite Language Switcher or Zanto could be helpful. I did not try these though, so I can’t recommend.

    GL with it!

    Thread Starter TrevorJones

    (@trevorjones)

    Very new to WP, I kind of understood multisite but wasn’t sure where to post about this (kind of related).

    I would have chosen the multisite approach but I kind of had this lumped on me and it’s too far down the line to go back (course website with all courses/quizzes already complete in both languages…) I’ve also looked into Polylang but again, too much work to go back…

    Now the site is in it’s final stages I’ve just been implementing the course purchase which involves the customer creating an account which is activated after they complete a payment through WooCommerce plugin. The main issue is that the sites have been set up to use separate user/usermeta tables in different databases… So purchasing a site licence in one language doesn’t create an account in the other sites database. I need both main EN site and the subdirectory site to use the same user tables.
    The database looks like this:
    site_wp1
    >wp1_users
    >wp1_usermeta

    site_wp2
    >wp2_users
    >wp2_usermeta

    I think targeting site_wp1.wp1_users from the subdirectory site is causing the problem as the query on login/out seems to be appending site_wp2. before the query ending up with “site_wp2.site_wp1.wp1_users”

    Thread Starter TrevorJones

    (@trevorjones)

    I suppose could it be a solution to just copy all tables from the site_wp2 database into the wp1 database, then setting both wp-config files to use the wp1 db but different table prefixes…
    Probably how I’m now guessing it’s supposed to be set up?

    EDIT

    Well, I just tried that and problem solved!
    Looks like no way to access another databases user/meta tables?
    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shared login between subdirectory install’ is closed to new replies.