2

How can I import users fom a CSV file in Drupal 8?

I’ve found this module but it is not updated for Drupal 8:

https://www.drupal.org/project/user_import

I think that I can make an import directly with a MySQL script but is it possible with Drupal (I know I can insert datas directly into database but I don't know if Drupal system will allow that method)?

I’ve found this question but it is not exactly what i need : Importing a bunch of users from csv spreadsheet file into Drupal 8

I import data from a csv file and it is not a migration from a drupal site.

1
  • 2
    It doesn't matter if the source isn't a Drupal site. Migrate is designed to work with various datasources, which has great support for CSV files of data.
    – Kevin
    Commented Sep 21, 2017 at 14:09

4 Answers 4

1

To make it with Migrate you need to setup Migrate Plus, Migrate Tools and Migrate Source CSV together, there is lot of examples in the web already:

http://valuebound.com/resources/blog/how-to-migrate-users-from-a-csv-file-drupal-8

https://agencychief.com/blog/drupal-8-csv-migration

https://www.mtech-llc.com/blog/lucas-hedding/migrating-using-csv

2
  • Thank you. It is exactly what i need. Your 3 links are really interesting. I’ve used the 1st one and it works. The 2nd is based on a custom module and i will try it. The 3rd is written by the maintainer of the D8 Migrate Source CSV contrib module so it s also an excellent article. Commented Sep 22, 2017 at 8:59
  • So i can import a list of users. Now, i have to import datas in a custom module that contains datas related to the user. I see it is possible but didn’t try it yet : drupal.org/docs/8/api/migrate-api/migrate-process-plugins/… Commented Sep 22, 2017 at 9:01
2

I think that I can make an import directly with a MySQL script but is it possible with Drupal (I know I can insert datas directly into database but U don't know if Drupal system will allow that method)?

Instead of MySQL this would be a Drupal method to insert users by using the Entity API:

$user = User::create([
  'name' => 'foobar',
  'mail' => '[email protected]',
  'status' => TRUE,
]);
$user->save();

So if you don't want to use Migrate there are other ways for such a simple import task. You can use a php library of your choice to fetch the data and then add the user entities one by one. I answered a similar question for importing nodes at a time when Migrate was still in alpha: Is there a way to migrate only nodes?

0

Here I found the solution for it. Please follow this link https://github.com/steveoliver/user_import and install the extended module. You can import the user data file through this path (path: '/admin/people/import').

1
  • Interesting. I’ll try it. But I see that it only handles fname,lname,email. In @drupalranger answer, there are links that explain how to import custom datas (like job, image, etc.) Commented Mar 20, 2018 at 9:01
0

User CSV Import is the module you want.

Migrate is a powerful and robust platform for integrating any arbitrary data source, but User CSV Import is tailor made for uploading CSVs of user data.

https://www.drupal.org/project/user_csv_import

There are other modules, like Bulk User Registration, which are less featureful. For example Bulk User Registration doesn't support any fields - you must manually write code to handle fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.