concrete/src/User/RegistrationService.php
public function getNewUsernameFromUserDetails($email, $suggestedUsername = '', $firstName = '', $lastName = '')
    {
        $baseUsername = $this->stringToUsernameChunk($suggestedUsername);
        if ($baseUsername === '') {
            $firstName = $this->stringToUsernameChunk($firstName);
            $lastName = $this->stringToUsernameChunk($lastName);
            if ($firstName !== '' || $lastName !== '') {
                $baseUsername = trim($firstName . '_' . $lastName, '_');
            } else {
                $mailbox = strstr((string) $email, '@', true);
                $baseUsername = $this->stringToUsernameChunk($mailbox);
            }
            if ($baseUsername === '') {
                $baseUsername = 'user';
            }
        }
        $username = $baseUsername;
        $suffix = 1;
        while ($this->userInfoRepository->getByName($username) !== null) {
            $username = $baseUsername . '_' . $suffix;
            ++$suffix;
        }

        return $username;
    }
public function getNewUsernameFromUserDetails($email, $suggestedUsername = '', $firstName = '', $lastName = '')
    {
        $baseUsername = $this->stringToUsernameChunk($suggestedUsername);
        if ($baseUsername === '') {
            $firstName = $this->stringToUsernameChunk($firstName);
            $lastName = $this->stringToUsernameChunk($lastName);
            if ($firstName !== '' || $lastName !== '') {
                $baseUsername = trim($firstName . '_' . $lastName, '_');
            } else {
                $mailbox = strstr((string) $email, '@', true);
                $baseUsername = $this->stringToUsernameChunk($mailbox);
            }
            if ($baseUsername === '') {
                $baseUsername = 'user';
            }
        }
        $username = $baseUsername;
        $suffix = 1;
        while ($this->userInfoRepository->getByName($username) !== null) {
            $username = $baseUsername . '_' . $suffix;
            ++$suffix;
        }

        return $username;
    }
public function getNewUsernameFromUserDetails ( $ email , $ suggestedUsername = '' , $ firstName = '' , $ lastName = '' ) { $ baseUsername = $ this -> stringToUsernameChunk ( $ suggestedUsername ) ; if ( $ baseUsername === '' ) { $ firstName = $ this -> stringToUsernameChunk ( $ firstName ) ; $ lastName = $ this -> stringToUsernameChunk ( $ lastName ) ; if ( $ firstName !== '' || $ lastName !== '' ) { $ baseUsername = trim ( $ firstName . '_' . $ lastName , '_' ) ; } else { $ mailbox = strstr ( ( string ) $ email , '@' , true ) ; $ baseUsername = $ this -> stringToUsernameChunk ( $ mailbox ) ; } if ( $ baseUsername === '' ) { $ baseUsername = 'user' ; } } $ username = $ baseUsername ; $ suffix = 1 ; while ( $ this -> userInfoRepository -> getByName ( $ username ) !== null ) { $ username = $ baseUsername . '_' . $ suffix ; ++ $ suffix ; } return $ username ; }
Create an unused username starting from user details.

@param string $email The user's email address
@param string $suggestedUsername A suggestion about the username
@param string $firstName The user's first name
@param string $lastName The user's last name

@return string
Create an unused username starting from user details .