function hook_email_registration_name in Email Registration 8
Same name and namespace in other branches
- 7 email_registration.api.php \hook_email_registration_name()
Implement this hook to generate a username for email_registration module.
Other modules may implement hook_email_registration_name($account) to generate a username (return a string to be used as the username, NULL to have email_registration generate it).
Parameters
\Drupal\user\UserInterface $account: The user object on which the operation is being performed.
Return value
string A string defining a generated username.
1 invocation of hook_email_registration_name()
- email_registration_user_insert in ./
email_registration.module - Implements hook_ENTITY_TYPE_insert().
File
- ./
email_registration.api.php, line 28 - Documentation for email_registration module API.
Code
function hook_email_registration_name(UserInterface $account) {
// Your hook implementation should ensure that the resulting string
// works as a username. You can use email_registration_cleanup_username($name)
// to clean up the name.
return email_registration_cleanup_username('u' . $account
->id());
}