diff --git a/app/Models/User.php b/app/Models/User.php index 413ed98a5f..f163ba217c 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -379,6 +379,18 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo } elseif ($format=='firstname') { $username = str_slug($first_name); } + elseif ($format=='firstinitial.lastname') { + $username = str_slug(substr($first_name, 0, 1). '.' . str_slug($last_name)); + } + elseif ($format=='lastname_firstinitial') { + $username = str_slug($last_name).'_'.str_slug(substr($first_name, 0, 1)); + } + elseif ($format=='firstnamelastname') { + $username = str_slug($first_name) . str_slug($last_name); + } + elseif ($format=='firstnamelastinitial') { + $username = str_slug(($first_name.substr($last_name, 0, 1))); + } } $user['first_name'] = $first_name; diff --git a/resources/lang/en-GB/general.php b/resources/lang/en-GB/general.php index 90ad774cc6..907a823e32 100644 --- a/resources/lang/en-GB/general.php +++ b/resources/lang/en-GB/general.php @@ -88,6 +88,9 @@ 'firstname_lastname_underscore_format' => 'First Name Last Name (jane_smith@example.com)', 'lastnamefirstinitial_format' => 'Last Name First Initial (smithj@example.com)', 'first' => 'First', + 'firstnamelastname' => 'First Name Last Name (janesmith@example.com)', + 'lastname_firstinitial' => 'Last Name First Initial (smith_f@example.com)', + 'firstinitial.lastname' => 'First Initial Last Name (j.smith@example.com)', 'first' => 'First', 'first_name' => 'First Name', 'first_name_format' => 'First Name (jane@example.com)', 'files' => 'Files', diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index e068d7fb1e..5a1ad2ddd3 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -88,6 +88,11 @@ 'firstname_lastname_underscore_format' => 'First Name Last Name (jane_smith@example.com)', 'lastnamefirstinitial_format' => 'Last Name First Initial (smithj@example.com)', 'first' => 'First', + 'firstnamelastname' => 'First Name Last Name (janesmith@example.com)', + 'lastname_firstinitial' => 'Last Name First Initial (smith_f@example.com)', + 'firstinitial.lastname' => 'First Initial Last Name (j.smith@example.com)', + 'firstnamelastinitial' => 'First Name Last Initial (janes@example.com)', + 'first' => 'First', 'first_name' => 'First Name', 'first_name_format' => 'First Name (jane@example.com)', 'files' => 'Files', diff --git a/resources/macros/macros.php b/resources/macros/macros.php index 63e8e5860e..94f8ddcce9 100644 --- a/resources/macros/macros.php +++ b/resources/macros/macros.php @@ -469,7 +469,10 @@ Form::macro('username_format', function ($name = "username_format", $selected = 'filastname' => trans('general.filastname_format'), 'lastnamefirstinitial' => trans('general.lastnamefirstinitial_format'), 'firstname_lastname' => trans('general.firstname_lastname_underscore_format'), - + 'firstinitial.lastname' => trans('general.firstinitial.lastname'), + 'lastname_firstinitial' => trans('general.lastname_firstinitial'), + 'firstnamelastname' => trans('general.firstnamelastname'), + 'firstnamelastinitial' => trans('general.firstnamelastinitial') ); $select = '