I need to register 1000+ usernames at once. How to do it?

Or is there any way to disallow from registering 1000+ usernames? People could not register certain usernames.

I need to reserve these usernames for payed registration.

  • For example I have a list like this: username1, username2, userhame3 ... username1000.
    – ttt
    Oct 10, 2016 at 12:38

1 Answer 1


You can do this by code, alter the registration form (hook_form_user_register_form_alter), in a custom module like:

function MY_MODULE_form_user_register_form_alter(&$form, &$form_state, $form_id) {
    $form['validate'][] = 'reserved_usernames';

And then implement the validation (in the same MY_MODULE.module file) method like:

function reserved_usernames ($form, &$form_state) {
  $reserved = array();
  $reserved[] = 'reserved_name';
  $reserved[] = 'reserved_name_1';
  $reserved[] = 'reserved_name_2';
  $reserved[] = 'reserved_name_3';
  $reserved[] = 'reserved_name_4';
  $reserved[] = 'reserved_name_5';

  if (in_array($form_state['values']['name'], $reserved)) {
    form_set_error('name', t('The name %name cannot be taken.', array('%name' => $form_state['values']['name'])));
  • You mean I need to make a special module? rémy, I do not understand how and where to add my list of usernames which I need to reserve.
    – ttt
    Oct 10, 2016 at 11:03
  • yes - you need to make a custom module, or this code could also be placed in your theme, but I would not suggest that. I updated the question to show you the use with an array.
    – rémy
    Oct 10, 2016 at 11:24
  • But I do not understand how and where to add restricted usernames. A list of disallowed usernames. 1000 or 2000 usernames.
    – ttt
    Oct 10, 2016 at 12:17
  • the array $reserved contains the restricted names. this also could be loaded form DB of where ever ...
    – rémy
    Oct 10, 2016 at 12:28
  • But there is only single username in your sample. I talk about bulk registration or reservation.
    – ttt
    Oct 10, 2016 at 12:33

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.