How to export and import users in WordPress –

Hosting Mautic QuickStart -50% with support in Spanish
24 hours and free training

Send up to 1,000,000 emails/year. Mautic support in Spanish 24 hours, 365 days

Like any content management system, WordPress, in addition to managing content itself, despite the redundancy, has its own system to manage users.

As you can imagine, users are, in the end, the people who log into the system to do different tasks: be it managing the site, creating entries, managing comments or if you have an e-commerce, managing orders, etc.

If you have a blog with WordPress or a
you have at least one user under your name, probably an administrator.

Before talking about how to import or export users in bulk, we are going to see how WordPress manages them, what data they contain, what capabilities they have, what roles exist… in order to see the process of importing or exporting them from a complete perspective. and understand all its details.

Once all this is understood, we will proceed to explain how to import and export users in bulk with WordPress with the plugin, a plugin that I developed, maintain and that I have the pleasure of improving.

Today it is the most popular plugin to import users in the WordPress ecosystem and I think it can be very useful (there are more popular general import plugins, but to import only users, this is the one with the most active installations).

Users in WordPress

As in any other online system, when we interact with WordPress, as people, we do so either identified or not.

If you are unidentified, without logging in, you will do so as a visitor. At the programming level, the function tells you with true or false if the user is authenticated or not.

If you are not a visitor, but a user of the site, you will be for two reasons:

  1. Because someone has previously registered you, if you are the administrator of the site, you will have registered in the installation, at the moment that you are expressly asked for the name and password of the first administrator user
  2. Because you are logged in, either through the standard login form (wp-login.php) or any other login form you use such as those provided by plugins like

The a priori registration is only done once and the login is done a priori each time you access the site.

What data defines a user in WordPress?

Our WordPress user has at least three basic data and a role, that is the minimum that a WordPress user can have:

  • Username.
  • Password.
  • Email.
  • Role.

The username and the email can coincide, but for database purposes, they will be two different data. As you can imagine this is the minimum because it is necessary:

  • A username and password with which to log in.
  • An email with which to communicate.
  • A role that identifies what capabilities the user has in the system, an administrator who manages everything is not the same as a subscriber, which is the most basic role that exists.
See also  Problems finishing configuring the Wordfence plugin

It is not the objective of this post to talk about roles, but basically to tell you that each role, which has a user; It has a number of capabilities. So that the system determines what capabilities each user has. You can create new roles or edit existing ones directly in code or with a plugin like , highly recommended for this task.

Besides, I recommend that you read the documentation if you want to delve deeper into this topic.

Apart from these four basic data, WordPress can store by default the following fields for each user:

In addition to a few other internal data such as when the user registered, what is the color scheme used in the panel or whether or not the user must connect via SSL. We see this data in “My profile” or in “Edit user” in the WordPress backend.

If we need more data, which we almost certainly need in any project we develop, the wp_usermeta table allows us to store any other data we want for a user. For example, WooCommerce uses this table to store data such as the address, city, or province of registering customers.

The problem of registering many WordPress users at once: importing users

Now you may be wondering why it may be necessary to have a tool to import, that is to say, register many users in bulk at one time. If you have a blog, you will find this possibility rare. You will probably have only one user or at most some more. That is, you as administrators and perhaps the odd author.

However, as you well know, WordPress today is not just a content management system to create logbooks. With WordPress today you can create all kinds of web systems:

As you can understand, all these plugins handle much more data than we have counted before and for many more users. For example, in the case of WooCommerce we have, as a minimum, the following metadata for each client:

  • billing_first_name
  • billing_last_name
  • billing_company
  • billing_address_1
  • billing_address_2
  • billing_city
  • billing_postcode
  • billing_country
  • billing_state
  • billing_phone
  • billing_email
  • shipping_first_name
  • shipping_last_name
  • shipping_company
  • shipping_address_1
  • shipping_address_2
  • shipping_city
  • shipping_postcode
  • shipping_country
  • shipping_state

That are handled in the “My addresses” screen of the “My account” page as we can see below:

Remember that WooCommerce allows us by default to establish for each order and for each customer this difference, a billing address and a shipping address. The first will be the “billing address” and the second the “shipping address”. Then we have for each of them: name, surname, company, two lines for the address, city, postal code, country and state. Apart from billing we also have an email and a telephone.

See also  Slider Revolution plugin

Imagine having to fill in data for 100 clients with 20 metadata of this type, apart from what WordPress already asks for by default. Think that even if the email is the same, we will have to fill in the WordPress email and the WooCommerce billing email; or for example, in the case of name and surname, the name and surname must be included three times (WordPress, and twice in WooCommerce, billing and shipping address).

Keep in mind, that many who come to WordPress to use it in one of its many forms come from another system, either online or offline. If you want examples of offline uses that happen to WordPress, I will tell you cases that we have found:

  • There are those who have a physical store and want to register all their customers in their online store to interact.
  • Or an academy that is going to include all the students in a WordPress so that they can access an elearning based on LMS Course.
  • A company that wants to create an Intranet with WP Customer Area for their employees to view internal data.

And good online cases, you can think of all you want. All free systems (PrestaShop, Magento, Joomla!, Drupal, etc.) or owners; that they go to WordPress, which are more every day, bring with them, among other things, users with data that usually needs to be imported in bulk.

Just as we need to import, we can have the opposite, export the data of our users. Either to import them to another WordPress, to migrate them to another system or because we need to treat them with a separate spreadsheet or database for any other reason.

Install plugin

After talking about users, roles, their metadata, how users are used in different scenarios with WordPress, let’s explain how to import them with a plugin that I told you about: .

The first thing will be to install it. Being a free plugin, available in the repository, you only have to look for it in:

  1. Your WordPress dashboard.
  2. Under Plugins & Add New.
  3. Search for “Import users” and install it.

Once you have it installed, you will have in “Tools” a new element called “Import users from CSV”. What remains for us now is to have the users prepared.

If you have another WordPress you can do it directly, accessing that option and choosing the “Export” tab, which is the second one that appears. There you have a button to export a CSV with the correct format to send the users with all their data and metadata to another site.

If not, we are going to explain how to create a correct CSV to be able to import the data successfully. The first thing is to have a good tool to handle CSV. This type of file, from the English “comma separated values”, that is, “values ​​separated by commas”, is a very simple type of file to handle and at the same time very powerful.

See also  Woocomorce payment market

To give you an idea, it allows you to handle an Excel-type file, that is, with rows and columns, in a very simple and light way. That is why today it is a de facto standard when it comes to sending data of this type, in table form and in a simple way, between different systems.

Although Microsoft Excel allows you to save your files as CSV, I personally recommend u (even Google Drive). As you can imagine, I have been handling imports of this type for many years and these solutions have given me fewer problems than Microsoft’s, why? Because they delimit values ​​better and we make sure the data is in UTF-8.

The fact of saving a file of this type with the character set UTF-8 is very important for users like us, where our language has characters that are not contemplated in the standard ASCII and can give us problems with other character sets. I am referring to the eñe and all vowels accented with accents.

import users

The first thing is to create a new file and start filling in the first row. The first row represents “the shape” that the data will have, so we have to prepare it first, and then fill in the second row onwards, data for each user.

The first two columns have to be:

  • Username.
  • Email.

This is so because, as we said before, they are two basic and necessary data. Those are the only columns that are mandatory and the only ones that have to be there in that order, from there, the rest we can put in the order we want as long as we write the name of the column correctly.

In addition to importing the users, the system sends them an email with their data, among them we can include the password. For the password we can:

  • If you don’t create a column for passwords: Passwords will be generated automatically.
  • If you create a column for the passwords (which you should call “password”: if the cell is empty, the password will not be updated; if the cell has a value, it will be used as the password.

When I talk about updating you may wonder what I mean if we are importing users. And it is that in addition to creating new users in a massive way, if the user already exists, we can also update it in a…

Loading Facebook Comments ...
Loading Disqus Comments ...