0

I am curerently working on a project in which one site act as a parent site and other sites will act as child sites. All of these sites will come under same domain name.

For example my parent site url will be like " www.mysite.com". And the other sites url will be like " www.mysite.com/childsite "

Each of these sites have seperate wordpress installation and database. What i am looking for is that once I login to the parent site dashboard, then i will have to get access to all the child sites dashboard without having to sign in to each sites seperatly.

Thanks in advance

  • What about the database of those sites ? Does they share same database with different prefix or they have different database for each of them ? – CodeMascot Nov 7 '16 at 9:05
  • Each sites have separate databases – Unnikrishnan R Nov 7 '16 at 9:07
  • It's an old solution. wp-includes/capabilities.php does not include the following line anymore: $this->cap_key = $wpdb->prefix . 'capabilities'; Keep searching. Good luck. – w.wa Jan 22 '17 at 21:00
0

As far I researched separate WordPress installation with separate database is not possible using WordPress default trick unless you do some other tricks like "Logging in through API" or any kind of that.

So in your situation I think there are two way you can do that.

  1. You can use WordPress multisite installation and create the second or child blog in a sub directory. This you you can authenticate user once then redirect them to where you want.

  2. Make sure that all the sub sites are installed in same database with different database table prefix. Then define the custom user table in wp-config.php.

For second method-

// Once the sub site has been installed, add these two lines to the sub site's wp-config.php file, just before this line:

/* That's all, stop editing! Happy blogging. */

//Add these two lines:

define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USERMETA_TABLE', 'wp_usermeta');

// Make sure you replace “wp_” by the first website table prefix.

If you get don’t have sufficient permissions error on profile page like below-

You do not have sufficient permissions to access this page.

Then in your sub site WordPress installation, wp-config.php, under define(‘CUSTOM_USERMETA_TABLE’, ‘wp_usermeta’); add-

define('CUSTOM_CAPABILITIES_PREFIX', 'wp_');

Then you have to find this line in wp-includes/capabilities.php

$this->cap_key = $wpdb->prefix . 'capabilities';

and replace it with-

if (defined ('CUSTOM_CAPABILITIES_PREFIX')) {
    $this->cap_key = CUSTOM_CAPABILITIES_PREFIX . 'capabilities';
} else {    
    $this->cap_key = $wpdb->prefix . 'capabilities';
}

If you want to stay logged in to all site then you need to set all the WordPress sites to use the same cookies. At the moment each website has its own cookies parameters, so your two websites have to use the same cookies parameters. So, still in wp-config.php of the sub site, change the COOKIE_DOMAIN with the url of the parent site:

define('COOKIE_DOMAIN', '.domain.com'); //replace with your domain name (the parent site)
define('COOKIEPATH', '/');

Hope that helps.

| improve this answer | |
  • To whoever down voted this answer, would you please explain why you have down voted this one ? I'm kinda curious. – CodeMascot Feb 1 '18 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.