diff --git a/email_registration.module b/email_registration.module index e12b5c972e3c10c470c83c296213cbaac9a2d5b3..dc77ef450ef5dc274a8f9313f8f1913168c456f9 100644 --- a/email_registration.module +++ b/email_registration.module @@ -9,6 +9,11 @@ * Implements hook_user_insert(). */ function email_registration_user_insert(&$edit, &$account, $category = NULL) { + // Don't create a new username if one is already set. + if (!empty($account->name) && strpos($account->name, 'email_registration_') !== 0) { + return; + } + // Other modules may implement hook_email_registration_name($edit, $account) // to generate a username (return a string to be used as the username, NULL // to have email_registration generate it). @@ -59,7 +64,7 @@ function email_registration_user_insert(&$edit, &$account, $category = NULL) { */ function email_registration_form_user_register_form_alter(&$form, &$form_state, $form_id) { $form['account']['name']['#type'] = 'hidden'; - $form['account']['name']['#value'] = user_password(); + $form['account']['name']['#value'] = 'email_registration_' . user_password(); $form['account']['mail']['#title'] = t('E-mail'); }