4

The user import modules exists for Drupal 7, but how would one import a list of user from a csv file into Drupal 8? And once they are imported, have them blocked by default.

Now when the users come to the site to register, they can only register with one of those imported accounts on the csv. So that means you cannot create a new account, but only unblock an existing account in the system. How would one accomplish this setup?

2
  • 1
    You can use the migrate module. With the migrate_csv module.
    – Eyal
    Jun 10, 2016 at 7:15
  • 2
    Can you elaborate? https://www.drupal.org/node/2574707 looks promising, but it's talking about adding nodes rather than users. Jun 14, 2016 at 14:15

1 Answer 1

2

I suggest setting up a Migration using Migrate CSV. When Feeds is ready, it should be possible, but it looks incomplete at the time of posting.

Using the migrate code that you implement, set the accounts as blocked by calling $user->block() per User import.

Block any anonymous user registrations, this will make new user additions possible only by admins.

In place of the user reg form, create a new custom form using Webform module or core Contact module. You can replicate the fields from the reg form of use to you there. On form submission, using a custom module including a hook_form_FORM_ID_alter, do a check on the submitted form for email address and verify if it matches, then call $user->activate() to unblock the user account.

Or if Rules module provides you the necessary settings through the UI, you could try the email address check using that, but this module maybe incomplete for this type of check at present.

Your Answer

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

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