Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save colepacak/bd8125c3d9bb2c46992fae3c328d5e0a to your computer and use it in GitHub Desktop.
Save colepacak/bd8125c3d9bb2c46992fae3c328d5e0a to your computer and use it in GitHub Desktop.
Email Registration - Allow username when registering
diff --git a/email_registration.module b/email_registration.module
index e172bd2..056c800 100644
--- a/email_registration.module
+++ b/email_registration.module
@@ -123,9 +123,6 @@ function email_registration_cleanup_username($name) {
* Implements hook_form_FORM_ID_alter().
*/
function email_registration_form_user_register_form_alter(&$form, FormStateInterface $form_state) {
- $form['account']['name']['#type'] = 'value';
- $form['account']['name']['#value'] = 'email_registration_' . user_password();
- $form['account']['mail']['#title'] = t('E-mail');
}
/**
@@ -144,8 +141,8 @@ function email_registration_form_user_pass_alter(&$form, FormStateInterface $for
function email_registration_form_user_login_form_alter(&$form, FormStateInterface $form_state) {
$config = \Drupal::config('email_registration.settings');
$login_with_username = $config->get('login_with_username');
- $form['name']['#title'] = $login_with_username ? t('E-mail or username') : t('E-mail');
- $form['name']['#description'] = $login_with_username ? t('Enter your e-mail address or username.') : t('Enter your e-mail address.');
+ $form['name']['#title'] = $login_with_username ? t('E-mail or display name') : t('E-mail');
+ $form['name']['#description'] = $login_with_username ? t('Enter your e-mail address or display name.') : t('Enter your e-mail address.');
$form['name']['#element_validate'][] = 'email_registration_user_login_validate';
$form['pass']['#description'] = t('Enter the password that accompanies your e-mail.');
// Allow client side validation of input format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment