Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to transfer users safely from one site to another with all... WordPress

  • SOLVED

How to transfer users safely from one site to another with all user meta and passwords.

OK I have developed a new wordpress website for my client, but he need to transfer all existing users over along with the custom roles, meta data, passwords.

How easy is this to do? I am comfortable using PHP my admin..

I already have some existing users on my on my new site. Will this complicate things.


And also, the wp salts have anything to do with it?


I'm not sure how I will award people but any one with useful info, i would be much thank ful.


Josh.

Answers (6)

2014-01-29

John Cotton answers:

<blockquote>I already have some existing users on my on my new site. Will this complicate things</blockquote>
Almost certainly.

They will use IDs also assigned to users in the other site and since the ID is used as a foreign key on tables like user_meta, things will get very confused.

Also, passwords won't transfer without using the same salts (they are used as a key for the random generator). If the two sites have different salts, one set of passwords will cease to work.

So it needs to be done in code (and your users won't be able to keep passwords).

If it were me, I'd write some PHP to do it, but you might find a plugin like this does what you need:

http://wordpress.org/plugins/cimy-user-manager/

I've never used it, but it seems to cover what you mention.

JC


Josh Cranwell comments:

Thanks Jon.

OK how about, I just transfer the salts from the old site?

But then just replace the old existing users tables with on the old site to the new. Will this work?

I dont really need the old users.

But what will happen to my page authors, with they switch to user ID? Lets say user 6 created a page. Would that page author then change to user 6 in my new user list?

Will that work?


John Cotton comments:

<blockquote>OK how about, I just transfer the salts from the old site?</blockquote>
You can do that, but the password of users on the new site would need to be reset.

<blockquote>But then just replace the old existing users tables with on the old site to the new. Will this work?</blockquote>
To some extent, although other tables might get foreign key errors (for example wp_posts has post_author as a user id; changes to the user table will potentially give authorship to a different user).

<blockquote>But what will happen to my page authors, with they switch to user ID? Lets say user 6 created a page. Would that page author then change to user 6 in my new user list</blockquote>
That's precisely the problem. And for any other tables you might have that contain user ids

However what you can is update those ids after you import the users.

Before you begin, make your self a little translation table (old user id, new user id) and then run some SQL on affected tables.

So, wp_posts would be

UPDATE wp_posts SET post_author = $new_id WHERE post_author = $old_id

for each line (that's a very simple example but you'll get the idea.


Josh Cranwell comments:

OK thanks John appreciate you help.

I will give it ago.

I will leave this thread open for a bit to if you don't mind


John Cotton comments:

<blockquote>I will leave this thread open for a bit to if you don't mind</blockquote>

Sure.

Backup your DB before you begin and also be sure you've got a list of all tables that contain user ids as foreign keys.


Josh Cranwell comments:

Thanks for your advice. Was useful

2014-01-29

Balanean Corneliu answers:

For posts author you can asign all to your own account.

2014-01-30

Ryan S answers:

Here's another option in PHPMyAdmin,
First: backup existing user table wp_usermeta and wp_users
Second: is export your old wp_usermeta and wp_users tables
Third: remove your new wp_usermeta and wp_users tables and import the new one you've just download or in second step.

Just like that, you've done moving all users into your new WordPress site.
NOTE: If your user have something like user meta fields, then we might export it in wp_options table too.

wp_ = this depends on what your table prefix is.


Hope that helps

2014-01-31

Deepak answers:

For the solution please follow the four steps may be it will be worked for you?

Step 1: Backup Your WordPress Database Using phpMyAdmin

Before transferring your WordPress blog, it is recommended that you make a backup of your database using phpMyAdmin. Once you have successfully logged into phpMyAdmin:

Click on the name of the database which contains your WordPress blog.
Click Export in the top navigation menu.
Select the Quick option listed under the Export Method section.
Leave the selection in the format section as SQL .
Click Go.
Once completed, there will be a prompt to save the file. Simply click on Save as File; this will download a file named wordpress.sql to your desktop.

You have then successfully backed up your database

===============================================================
Step 2: Download/Upload All WordPress Files Using FTP

You will need to download ALL your files from your old host and upload them to your new host. This includes files from your themes folder and plugins folder. Make sure you also download any folders which were referenced outside of your blog's folder.
For example, if you are using a separate folder called images, located outside of the blog's folder, the images must be copied and uploaded to the new hosting location; otherwise, the site will contain a lot of broken links to images within the blog post.


=====================================================
Step 3: Create a New WordPress Database and Edit wp-config.php
Create a New Database

To create a new MySQL database:

From your control panel, click the MySQL Databases icon.
Create a new database with a name appropriate for your blog.
Create a database username and password.
Assign the new user to the new database and grant All Privileges.
For additional help creating a MySQL database, please see:


Editing the wp-config.php File

After creating a new database, you will need to edit the wp-config.php file, which is the WordPress configuration file. This specific configuration file reads directly from a database of your choosing.

To update the WordPress configuration file:

From your control panel, click the File Manager icon.
Navigate to the document root for the domain for which you are updating the WordPress.
Locate the file named wp-config (its normally in the group of files near the bottom).
Click to open the file, and locate the following lines so that they can be updated with the correct information:
/** The name of the database for WordPress */
define('DB_NAME', 'cpuser_dbname');

/** MySQL database username */
define('DB_USER', 'cpuser_uname');

/** MySQL database password */
define('DB_PASSWORD', '******');

/** MySQL hostname */
define('DB_HOST', 'localhost');
If you did not edit the file on the server via the File Manager with your new database settings, upload it to the root of your blog folder.

The configuration file is now set up with the new database; however, it does not contain any database tables. In order to correct this, you will need to import the information into the database.

======================================================================================
Step 4: Importing WordPress to the New Database

You can use either phpMyAdmin or BigDump to import your database. BigDump is the preferred option if you have a large database (10mbs or more). There is a step-by-step guide on how to use BigDump on its website.

Once you have logged into phpMyAdmin:

Click the name of the Database to which you wish to import the information.
Click the Import tab at the top of the page.
In the File to Import section, select the SQL based file from your computer that you wish to import.
Use Partial Import if you intend to skip a set number of code rows.
The Format and Format Specific Options sections can be left to their default values.
Click Go to initiate the import.

Note: Importing via phpMyAdmin is less strenuous on the browser compared to the SQL option (BigDump) since the query may take a long time and can sometimes crash your browser.


Josh Cranwell comments:

Thanks for you detailed answer but Ryan S answer worked.

2014-01-29

Bob answers:

can you tell that if any plugin is used to create custom role?
is there any other data for each user then standard wordpress fields?


Bob comments:

Please take backup of your database before doing anything.

I am not aware too much about your site, but may this may be help you.

you can use such plugin and try to export users.
http://wordpress.org/plugins/export-user-data/

and using http://wordpress.org/plugins/import-users-from-csv/ plugin
you can import users, but you might have to modify import plugin.

I never used any of theme but thought may be it become helpful to you.

2014-01-29

Hariprasad Vijayan answers:

Hello,

Did you read this article?
http://robbclarke.com/blog/how_to_move_users_from_one_wordpress_blog_to_another/

Hope it helps you to solve this. Please take a backup of your database before doing this.

Good luck.
Hariprasad