email_registration.api.php 956 Bytes
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Documentation for email_registration module API.
6 7
 */

8 9
use Drupal\user\UserInterface;

10 11 12 13 14 15 16 17
/**
 * @addtogroup hooks
 * @{
 */

/**
 * Implement this hook to generate a username for email_registration module.
 *
18
 * Other modules may implement hook_email_registration_name($account)
19 20 21
 * to generate a username (return a string to be used as the username, NULL
 * to have email_registration generate it).
 *
22
 * @param \Drupal\user\UserInterface $account
23 24
 *   The user object on which the operation is being performed.
 *
andypost's avatar
andypost committed
25
 * @return string
26 27
 *   A string defining a generated username.
 */
28
function hook_email_registration_name(UserInterface $account) {
29 30 31
  // 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.
32
  return email_registration_cleanup_username('u' . $account->id());
33 34 35 36 37
}

/**
 * @} End of "addtogroup hooks".
 */