Install Single Site To Multisite
Install Single Site To Multisite
Multisite Install
NOTE: The following is a very manual process, we have since released Multisite Tools 1.1 which
includes Pull a Single Site Install into a Subsite functionality.
Follow the steps below to convert a standalone WordPress site into a WordPress Multisite subsite.
Here are some of my environment details for context:
Cleanup Users
This is where things get a little tricky.
At this point all the database tables from the single site install of WordPress have been imported
into the multisite with their proper subsite prefix. However, both the “users” and “usermeta” tables
were imported with the new prefix too, but in a multisite install the users and usermeta tables are
global and hold information about all the users across all the subsites.
This means you need to carefully merge the users and their meta data from the wp_2_ prefixed
tables into the wp_users and wp_usermeta tables. You then need to update all their posts, comments
and other data to have the correct user_id.
By far the easiest way to do this is to simply run a little bit of SQL that copies the wp_2_users into
wp_users, and then inserts the wp_2_usermeta data into wp_usermeta with the new IDs of their
respective users. This takes advantage of the fact that the WordPress database schema does not
enforce unique usernames. If you’ve already go duplicated usernames in the data you’re importing,
you should fix that first. The SQL will be something like the following:
-- To enable matching of old and new user ids.
ALTER TABLE wp_users
ADD COLUMN old_user_id bigint(20) unsigned;
As well as updating posts and comments in the new subsite with the changed user ids, if you have
any other tables that hold user authored data (such as the old links table) you should update them
too.
Once you’re happy that everything is updated and working as intended, you can delete the used
wp_2_users and wp_2_usermeta tables from your multisite database.
This isn’t a perfect method of importing users as you may end up with duplicate users if your users
have created accounts on both the single site install or any of the sites hosted in the multisite
network. You could conceivably run something similar to the above SQL to merge and delete
duplicate users.