-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the WP Author Migration wiki. This documentation is intended to help understand when how to use this plugin to reconcile post authors on posts that have been moved from one WordPress site to another.
If you migrated a WordPress site from one multisite WordPress instance to another, using a migration method other than the provided WordPress Import/Export, there's a chance your posts are assigned to incorrect or non-existent authors. This plugin was originally created to deal with this problem when using the All-in-One WP Migration plugin to migrate a site from one multisite WordPress instance to another.
If you use the provided WordPress Import/Export plugin to migrate your content, particularly when you use the GUI, an author mapping screen is provided. The wp-cli command provides an --authors parameter that accepts several parameters for dealing with this problem. If you imported your content using the --authors=skip method, this plugin can help match up the authors.
To get started using the plugin, first install it on the site you're importing into and activate it. Once installed and activated, you will need a JSON file with the author information from the old site to proceed. Currently, the plugin only accepts a JSON file in the format provided by the wp user list --format=json command.
To create the JSON file using wp-cli, use the following steps:
- Remote into the server where the old site is hosted.
- Run one of the following commands based on your particular situation:
-
wp user list --format=json > /path/to/file/filename.json(Single site)* -
wp user list --format=json --url=<the_site_url> > /path/to/file/filename.json(Multisite)*
-
- Upload the
filename.jsonto a web server or copy to a location accessible from the server where the new site is hosted.
* The /path/to/file/filename.json path must be writable by the user that is currently running the wp-cli command. For multisite, the site URL must be provided.
Once you have your authors JSON file ready and in an accessible location, you are ready to perform the migration. The basic usage of the command is as follows:
wp wpam migrate <path-or-url-to-file> [--default-author=<ID,username,email>] [--set-default=<true/false>]
| Parameter Name | Required | Default | Description |
|---|---|---|---|
| path-or-url-to-file | Yes | N/A | The file path or URL to the author JSON file. |
| default-author | No | 1 | The ID, username or email of the default author to assign when a post cannot be matched to an existing user in the new site. |
| set-default | No | true | Determines if the default-author will be used. If this is set to false, any post which author cannot be matched to an existing user in the new site will be skipped. |
| post-type | No | 'any' | Determines which post types the migration will be applied to. The default is 'any', which will apply to any post types. Can be a single post type (i.e. --post-type=post) or a comma delimited list of post types (i.e. --post-type=post,page). |
In all of the examples provided the author JSON file will be named authors.json and the default author will be a created user with the ID of 4, a user name of testuser and an email of example@mydomain.com.
wp wpam migrate ~/authors.json
This example would look for the JSON file in the user's home directory and will set the post's author to 1 (which is generally the account that created the WordPress instance) if it exists.
wp wpam migrate https://www.example.com/files/authors.json
This example would try to download the JSON file from the provided URL and will set the post's author to 1 if it exists.
wp wpam migrate https://www.example.com/files/authors.json --default-author=4
wp wpam migrate https://www.example.com/files/authors.json --default-author=testuser
wp wpam migrate https://www.example.com/files/authors.json --default-author=example@mydomain.com
Thes examples would try to download the JSON file from the provided URL and will set the posts's author to 4 if it exists. The second and third commands are referencing the same user but using username and email, respectively, to identify the user.