From cfe229a80fa3948dde444d37404835fe0d45ddde Mon Sep 17 00:00:00 2001 From: gundalo Date: Tue, 25 Dec 2012 03:04:48 +0400 Subject: [PATCH] Issue #678434 by Jon Pugh, hadsie, mikeryan: Fixed Don't generate username if the account->user is already set. --- email_registration.module | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/email_registration.module b/email_registration.module index e12b5c9..dc77ef4 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'); } -- GitLab