Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter jeremy

    (@jeremy)

    OK, I got it working. Without the above help I would have been lost, but I did need to make a few tweaks and additions. Here’s the formula in case anyone else wants to do something similar.

    Edit the ‘wp-settings.php’ file for every site. Around line 73 you’ll see:

    if ( defined(‘CUSTOM_USER_TABLE’) )
    $wpdb->users = CUSTOM_USER_TABLE;

    Insert a couple of lines above that, and type the following:

    define(‘CUSTOM_USER_TABLE’, ‘wp_users’);

    This assures all blogs access the same user database. I tried adding that to the index.php as alphaoide suggested, but it didn’t work. In the settings file however, it’s golden.

    Then you have to edit the ‘wp-config.php’ file for every site. On line 5 you’ll see:

    define(‘DB_NAME’, ‘your_database_name’);

    All of your blogs should have an identical database name. Point them to whatever is your master blog with the user database you want to use. Then, on line 17 you’ll see:

    $table_prefix = ‘wp_’;

    This is important. Every blog needs to have a unique prefix. I left this default setting for the master blog, but for each additional blog I changed this to something new (ie. ‘wp2_’, wp_blog5′, etc.).

    You’re almost set. Now for each blog you must launch ‘/wp-admin/install.php’ and let it create all the new tables in your database. Once that’s complete, you should have separate working blogs sharing the same user database.

    Now, up til now, this works only if you’re creating fresh new WordPress blogs with no content yet. If you want to merge the user databases of two existing sites with existing content, it gets a little tricky. After following the above, you have to copy the tables from your old database(s) into the master ‘DB_NAME’ assigned above. I did this using PHPMyAdmin, which is an open source web-based MySQL manager. You can find this pre-installed by many web providers (can be hard to find) or you can install it yourself.

    To copy the tables between databases using PHPMyAdmin, select the database you want to copy FROM using the dropdown menu on the left. Then select a table below that menu. Click the Operations tab at the top of the screen. You’ll see the ‘Copy table to…’ box, in which you can select the master database that contains your users. Then next to that you have to type the unique header for that blog (from your ‘wp-config.php’ file) followed by an underscore and the original name of that table.

    For example, ‘wp_categories’ would be changed to ‘wp_blog2_categories’.

    Leave the default settings, and click Go. Do this for every table *EXCEPT* ‘wp_users’. I have not tried merging two user databases, and don’t know for sure what will happen if you try. It might work for all I know, but if users have identical accounts on two of your site, this could confuse the database. If anyone has success with this, I’d be curious to know. At the very least, this method will retain your sites’ content, though some users may have to re-register.

    That should be everything! Good luck to anyone else, and thanks to those who helped above. Sorry for the long post, but I hope someone finds this useful.

    Best,
    Jeremy

    Thread Starter jeremy

    (@jeremy)

    But this will just copy users over, right? I want everyone who creates an account on any of the sites to have access to all of them, whether they created an account a month ago or two weeks from now.

    Wonderful info guys, thanks. Haven’t commented out the code yet, but sounds like it will work.

    Yeah, sorry, I know this. That’s why I was excited to find the thread. Keep up the great work!

    This plug-in is looking great! I found the one on your site, but was disappointed that it didn’t include support for cover images. Please keep us posted about future versions. And thanks for making it!

    Yeah, works in 1.5! Brilliant!

    This thread was very helpful to me. Big thanks to you all. The only thing I didn’t see covered was the fact that “Site Admin” still links directly to the index.php file (Dashbard). You can circumvent this by creating a new index file, as cdr suggested (which is still a good idea), but I found that link inside “template-functions-general.php” in the /wp-includes folder.

    You can just change that link to point to profile.php instead, and that should take care of all references to the index. As a bonus, you can also change the text “Site Admin” to whatever you want. I choose “My Account.”

    Again, thanks all!
    Jeremy

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