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.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI 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.
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'])));
}
}