How to bulk import users into WordPress with WP-CLI

Recently, I was tasked with importing around 20,000+ users from a CSV file into WordPress. I spent some time trying out plugins to achieve this, but ran into nothing but trouble. Some would time-out, some would require ‘premium’ versions to import what I needed, and some would straight up not work.

WP-CLI to the rescue. You can easily bulk import users into WordPress with the following command:

wp user import-csv --skip-update file-name.csv

The fantastic thing is that if you’ve added custom fields for your users, the import-csv function supports this right out of the box:

Example of a CSV file of users

Your spreadsheet should look something like the above, with your standard WordPress fields as the headers. If you have custom fields, simply set that name as the column header, and WP-CLI will map them automatically. The output on the terminal will also notify you of users who have failed to import.

If you’re not using WP-CLI, I highly recommend it. In this instance, the import process took a fraction of the time than it would have when using an import plugin, without the extra bloat.