Saltar al contenido

As export and import WordPress users

febrero 2, 2020

 

Like any content management system, WordPress, and manage content itself worth redundancy, has its own system for managing users.

As you can imagine, users are at the end we started meeting people in the system for different tasks: either administer the site, create entries, manage comments or if you have an ecommerce, manage orders, etc.

If you have a blog with WordPress WooCommerce store or online, at the least have a user in your name, probably administrator.

Before talking about how to import or export massively users, let’s see how WordPress handles what data hosting, what capabilities they have, what roles exist … in order to see with a prospect completes the process of importing or exporting them and understand every detail.

Once understood this panorama, we will explain how to import and export users massively with WordPress plugin With CSV Import Users From Meta, plugin I developed, I maintain that I am pleased to be improving.

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

Table of Contents

  • WordPress Users
  • What data define a user in WordPress?
  • The problem of registering many WordPress users once: import users
  • Install the plugin
  • Import Users
  • E-mails and tasks cron
  • Conclusions

Users in WordPress

Like any other online system when we interact with WordPress, as people, we do or identified or unidentified.

If you are unidentified, without logging, you’ll do as a visitor. A programming level the is_user_logged_in () function tells you true or false if the user is authenticated or not.

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

a priori Registration is done only once and the login is made a priori each time you access the site.

What data define a user in WordPress?

Our WordPress user has the least three basic data and a role, that’s the least you can have a WordPress user:

  • Username.
  • password.
  • Email.
  • role.

The username and email, may coincide, but for purposes of database, data will be two differentiated. As you can imagine this is the minimum that is needed:

  • A user and password to login.
  • An email with which to communicate.
  • A role that identifies what capabilities the user has in the system, is not the same as an administrator who manages everything that a subscriber who is the most basic role there.

is not the purpose of this entry discuss the roles, but basically say that each role has a user; It has a number of capabilities. So that the system determines what capabilities each user. You can create new roles or edit existing code directly or with a plugin like User Role Editor, highly recommended for this work. Besides

I recommend you you read the documentation on «Roles and capabilities» if you want to delve deeper into this topic.

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

  • user_nicename: the user name version «kind to the URL» to create urls like author.
  • user_url: the url of the user.
  • display_name: the name displayed for the user in WordPress.
  • nickname: default is the same as the user name.
  • first_name: the name.
  • LAST_NAME surnames.
  • description: where we fill our biography.

user_url: URL the user.

first_name: the name.

addition to a few other internal data such as when the user was registered, which is the color scheme used in the panel or the user must connect via SSL or not. These data we see in «My Profile» or «Edit User» in the WordPress backend.

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

The problem of registering many WordPress users once: import users

Now you may ask why it may be necessary to have a tool to import, ie discharge, many users massively once . If you have a blog, you will be rare this possibility. Probably you will have only one user or at most some more. It ie you as administrators and perhaps some other author.

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

  • online stores with WooCommerce and Easy Digital Downloads.
  • membership sites with WooCommerce Membership, Paid Membership Pro, Pro or Ultimate Membership WP Members.
  • Social Networking with BuddyPress.
  • with bbPress Forum.
  • elearning sites with Sensei or WP LMS Course.
  • An intranet users with WP Customer Area.
  • among others.

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

  • 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

handled in the screen «My places» page » my account «as we can see below: Remember

default WooCommerce allows us to establish for each order and each customer is different, a direction d and billing and other shipping. The first is the «billing address» and the second the «shipping address». Then we have for each: name, company, two lines for the address, city, zip code, country and state. Apart for billing also we have an email and a phone.

Imagine having to fill data for 100 customers with 20 metadata such, apart from those already requested WordPress default. Remember that although email is the same, we will have to fill in the email WordPress and WooCommerce billing; or for example in the case of full name will include the name and surname three times (WordPress, and two in WooCommerce, billing address and shipping).

Be aware that many of those who come to WordPress for use in one of its many forms comes from another system, either online or offline. If you want examples of offline applications that pass WordPress cases I say that we have found:

  • Some people have a physical store and want to register all customers in their online store to interact.
  • Or an academy that will include all students in WordPress so that they can access a elearning based on LMS Course.
  • A company that wants to create an Intranet with WP Customer Area for your employees to see internal data.

cases

online Well, you can think all you want. ; All (PrestaShop, Magento, Joomla !, Drupal, etc.) or free systems owners WordPress passing, every day more, bring with them among other things users with data that is often necessary to import in bulk. Just

we need to import, we can have the opposite, export the data from our users. Whether to import another WordPress to migrate to another system or because we need to treat them with a spreadsheet or database for any other reason apart.

Install the plugin

After speaking users, roles, metadata, how people use in different scenarios with WordPress, we will explain how to perform an import thereof with a plugin that I commented: With CSV Import Users From Meta.

First, it will install the same. A being a free plugin available in the repository, you just have to look at:

once installed you may have, will have «Tools» a new element called «Import users from CSV». What remains now is to have users preparations.

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

If not, we will explain how to create the proper CSV to import the data successfully. The first is to have a good tool to handle CSV. This type of file, from the English «comma separated values», ie, «Comma Separated Values» is a kind of very simple handling and file in both very powerful.

To give you an idea can handle an Excel file type, ie with rows and columns, very simple and light. That is why today is a de facto standard when sending such data in tabular form and easily between different systems.

Although Microsoft Excel allows you to save your files as CSV, I personally recommend LibreOffice or OpenOffice (including Google Drive). As you can imagine there are many years of managing imports of this type and these solutions have given me less trouble than Microsoft, why? For better they define the values ​​and ensure that the data is in UTF-8.

The fact save 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 included in the ASCII standard and can give us problems with other character sets . I mean the Ene and all accented vowels with a tilde.

Import Users

What is to first create a new file and start filling the front row. The first row represents «how» to have the data, so we have to prepare first and then fill in the second row onwards, data for each user.

The first two columns must be:

  • Username.
  • Email.

This is because as we said before, there 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 can put it in the order we want whenever we write the name of the column well.

The system also import users, send them an email with your data, including the password can include. For the password can:

  • If you do not create a column for passwords: Passwords are automatically generated.
  • If you create a column for passwords (which you must call «password». If the cell is empty, the password will not be updated; if the cell has a value, is to be used as a password

when I talk to update you may ask what I mean if you are importing users. and also to create new users massively, if the user already exists, we can also update it in bulk.

besides the password, too we can include a column with the role that will have users:

  • If you do not create a column for profiles: profiles will be chosen from the field «default profile» in the import window
  • If you create a column called ‘role. default role ‘(default profile):’ if the cell is empty, the field profiles are selected ‘in the import window, if the cell has a value, will be used as a profile, if the perf yl there will be used which is default.

We will use the slug of roles, ie «subscriber» instead of «Subscriber» to refer to them in the CSV file. By the way, as a curious note say that although default WordPress does not allow this plugin we can include multiple roles per user, making the cell «role» has Comma Separated Values.

Other than those two columns «special» for roles and passwords, all other columns must match: Standard

    WordPress

  • The data import.
  • The metadata in question.

In the «Documents» tab have the list whole, not to come here to give more listings but to give you an idea, I give an example of each:

  • «display_name» to teach the display name of the user.
  • «shipping_postcode» to include the zip code of the billing address of the customer

And so with all WordPress data or metadata you please use. Have an example file in the tab «Documentation» can be a good basis for your work.

So filling the first row with different data will import and other rows with the user data itself will have import list. Keep the file as CSV, drive towards the first tab «Import» and then choose the default role and the file and ready.

The process will run and create and update users on the system.

mails and tasks cron Post

Before finishing wanted to comment on two things that allows the plugin I think interesting. The I introduce and now if you want to use them and have questions you can ask in the support of the plugin or comments on this post.

The first are the emails. You can send mail to each user being imported. This is important because then everyone will notice your new user. This email is configured in the «Mail» tab and that mail can include any data that is being imported or generated, as the password.

The system has a template system mail, if you use often imports and based on the type of import want to send a mail type or another.

On the other hand wanted to comment the possibility of cron tasks include import. Ie tasks that run from time to time independently. For example, the system once a day will read the CSV is located on a particular route and update the data.

This tool is very useful for synchronizing external databases with WordPress make integration between different systems or to update some value automatically from an external source. In Codection we often do this type of work and this plugin, it is a good basis on which asentamos if not complete development of the same.

Conclusions

Well, with this I finish this post on users , roles, and how data import and export in WordPress; I hope you have clarified some concepts that ye heard from a few others ever and of course you may have a new tool that allows you to import and integrations quickly and easily.

If you have any doubt, please tell me in the comments or as I said before, directly support the plugin.

If insurance professionals are subject ever I could have used this tool to use if you are not, I encourage you to you to try to create or update users with an Excel file, is comfortable and very quickly.