diff -u b/email_registration.module b/email_registration.module --- b/email_registration.module +++ b/email_registration.module @@ -45,7 +45,12 @@ // Ensure whatever name we have is unique. $new_name = email_registration_unique_username($new_name, $account->id()); - $account->setUsername($new_name)->save(); + $account->setUsername($new_name); + if ($account->isValidationRequired() && !$account->validate()) { + \Drupal::logger('email_registration')->error('Email registration failed setting the new name on user @id.', ['@id' => $account->id()]); + return; + } + $account->save(); } /**