admin on March 27th, 2012
Recently I was developing portal for nurses. I was trying to configure 2 WordPress installations. I needed them to be separate blogs. Multisite feature couldn't help me because secondary blog should contain huge database of agencies. And it would be just nightmare if both blogs will share same posts/comments tables in DB. Too many troubles I could get with MultiSite…
If you are in the same situation Solution is on this page for you!
It even works if your secondary blog located on subdomain.
How it works?
Here are 3 blogs:
For testing - just sign up on one of them (doesn't matter on which one) and you'll get registered to all 3 blogs!
- Both blog tables should share one database! (with different table prefixes)
- Access to phpMyAdmin for your DB (optional)
- WordPress CMS + root Cookie plugin + WP Orphanage Extended plugin
1) Prepare wp-config for your main blog and setup it
- By default your wp-config.php has $table_prefix = 'wp_'; I didn't change it here.
- Generate secret keys&salts here - https://api.wordpress.org/secret-key/1.1/salt/
- Replace default keys&salts by generated code above.
- Install WP for your main blog (let's call it "blog A").
2) Prepare wp-config for your main blog and setup it
- For second blog ("blog B") change table prefix to another one. For example $table_prefix = 'blog_';
- Add to this config your secret keys&salts from wp-config of blog A.
- Now install your "blog B" with the same login/pass for admin.
3) Install root Cookie plugin on both blogs.
Select checkbox in it's settings to enable subdomain support if needed (WP-Admin->Settings->root Cookie).
Looks like "root Cookie" has a little bug at this time. I've spent couple of hours of testing that when accidentally found that it works only when you add this code in wp-config for both blogs.
Don't forget to change "YourDomain.com" to domain name of your main blog.
Please let me know if you find the way to optimize cookies defining procedure (wp-config & root-Cookie plugin).
4) For both blogs install and activate WP Orphanage Extended plugin.
Visit setting page on both blogs (WP-Admin->Settings->WP Orphanage Extended).
Add all necessary prefixes there. In our example I've added "blog_" for blog A, "wp_" for blog B.
It will give access for users to their profiles on all installed blogs (doesn't matter on which one they registered).
The problem appears when you register on blog A, login there and try to open /wp-admin/profile.php on blog B or C.
In this case you'll see "You do not have sufficient permissions to access this page."
User must visit wp-login.php on blogs B and C. After that they can access their profiles normally.
5) For secondary WP blog define users&usermeta tables in the wp-config.php
Use table prefix assigned in your main blog config (for blog A - "wp_").
Here is the code from my blog B:
1 2 3
$table_prefix = 'blog_'; define('CUSTOM_USER_TABLE', 'wp_users'); define('CUSTOM_USER_META_TABLE', 'wp_usermeta');
6) One step closer to the end…
Now you can't access to dashboard for second blog as admin. That's because WP Orphanage Extended makes it accessible only for users (normally set to Subscribers), but not for Administrator and other staff.
I've made the script that fixes that. Download zip-archive here.
This script should be placed into the root folder (public_html) of your main blog.
Don't forget to remove this script from your site when done.
Otherwise you need to give access to yourself manually.
Open phpMyAdmin and go to your MainBlogPrefix_usermeta (for our example it is 'wp_usermeta').
Click "Insert" and fill fields.
user_id => 1
meta_key => SecondaryBlogPrefix_user_level
meta_value => 10
I'm not sure if this solution compatible with other versions of WP and plugins.
And I can't say troubles we can meet with that in future. But hope it will work like a charm.
What I'm waiting from you?
1) Please share your experience or ask for help here!
2) I hope someone can help with optimizing define cookies code.
3) Please link to this post when mentioning or reprinting this solution.
4) Subscribe to my blog and comments to this post. I'll get you updated for any changes.
I'm planning to use this solution on my main project. Just wish you to know that this question is very important for me too.