Tech Forums

Installing multiple Word Press blogs with common user database (upgrade pre WP 2.3.3 to max WP2.3.3)

User Rating:  / 0
PoorBest 

I wanted to create multiple word press installations in the same database but they needed to have a common user database. After much searching and experimentation, I found some posts on the word press support forum dealing with this sort of installation.

I finally managed to get that done and working. The procedure is listed below -

1. Create a database with your web host using my-sql. Lets say the database name is “wp-xyz” and user is ‘abc” with password-”qwerty”.
2. Place the Word Press directory in the required place in your website.

3. Now edit the wp-config.php file in your wordpress main directory –// ** MySQL settings ** //

define(’DB_NAME’, ‘wp-xyz’); // The name of the database
define(’DB_USER’, ‘abc’); // Your MySQL username
define(’DB_PASSWORD’, ‘qwerty’); // …and password
define(’DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value
// if that dosen’t work write your My-SQL hostname here

// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!

//e.g for first install you can have this value “wp_” for second you can have this “wp1_” or youca assign some meaningful /name like “myblog-”

4.Now install the database by opening your web browser and enterng the following–

http:////wp-admin/install

now follow the instructions that appear
5. Now repeat steps 1-4 with everything same except placing the Word Press files in a different directory and changing the name of the

$table_prefix

6. Now edit the /wp-config.php file and add the following –

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

In the above wp_users and wp_usermeta can be changed to whatever act as the primary tables for your blogs. If you only want to combine the users table but retain different role and capability settings under each blog, leave out the CUSTOM_USER_META_TABLE constant

7. Now edit the /wp-includes/capabilities.php file.

In the “wp_user” class edit the following line:

$this->cap_key = $table_prefix . 'capabilities';

Modifying that line so it reflects the table prefix of the *primary* users/usermeta table, for example:

$this->cap_key = 'wp_capabilities';

where the ‘wp_’ in 'wp_capabilities' means your main blog table prefix 1.e. your wp-install number 1 table prefix

8.  This process is now scalable repeat above procedure for further installs.

9. I havent taken the pains to have separate user permission for users to different Word Press installs however this is possible by

fiddling with  the wp-settings.php file in the following section

// Table names
$wpdb->posts = $table_prefix . 'posts';
$wpdb->users = $table_prefix . 'users';
$wpdb->categories = $table_prefix . 'categories';
$wpdb->post2cat = $table_prefix . 'post2cat';
$wpdb->comments = $table_prefix . 'comments';
$wpdb->links = $table_prefix . 'links';
$wpdb->linkcategories = $table_prefix . 'linkcategories';
$wpdb->options = $table_prefix . 'options';
$wpdb->postmeta = $table_prefix . 'postmeta';

Special thanks to Kafkaesqui @ wordpress.org most of the work was done by him as Moderator of support forums at word Press . The orginal posts can be viewed here–

http://wordpress.org/support/topic/80822?replies=12

http://wordpress.org/support/topic/42793?replies=8.

Site Login