@@ -42,6 +42,7 @@ protected function handle($row)
4242 public function createUserIfNotExists (array $ row )
4343 {
4444 // Pull the records from the CSV to determine their values
45+ $ this ->item ['id ' ] = $ this ->findCsvMatch ($ row , 'id ' );
4546 $ this ->item ['username ' ] = $ this ->findCsvMatch ($ row , 'username ' );
4647 $ this ->item ['first_name ' ] = $ this ->findCsvMatch ($ row , 'first_name ' );
4748 $ this ->item ['last_name ' ] = $ this ->findCsvMatch ($ row , 'last_name ' );
@@ -76,13 +77,18 @@ public function createUserIfNotExists(array $row)
7677 $ user_formatted_array = User::generateFormattedNameFromFullName ($ user_full_name , Setting::getSettings ()->username_format );
7778 $ this ->item ['username ' ] = $ user_formatted_array ['username ' ];
7879 }
79-
80- $ user = User::where ('username ' , $ this ->item ['username ' ])->first ();
80+
81+ // Check if a numeric ID was passed. If it does, use that above all else.
82+ if ((array_key_exists ('id ' , $ this ->item ) && ($ this ->item ['id ' ] != "" ) && (is_numeric ($ this ->item ['id ' ])))) {
83+ $ user = User::find ($ this ->item ['id ' ]);
84+ } else {
85+ $ user = User::where ('username ' , $ this ->item ['username ' ])->first ();
86+ }
87+
8188 if ($ user ) {
89+
8290 if (! $ this ->updating ) {
83- $ this ->log ('A matching User ' .$ this ->item ['name ' ].' already exists. ' );
8491 \Log::debug ('A matching User ' .$ this ->item ['name ' ].' already exists. ' );
85-
8692 return ;
8793 }
8894 $ this ->log ('Updating User ' );
@@ -109,7 +115,6 @@ public function createUserIfNotExists(array $row)
109115 $ user ->fill ($ this ->sanitizeItemForStoring ($ user ));
110116
111117 if ($ user ->save ()) {
112- // $user->logCreate('Imported using CSV Importer');
113118 $ this ->log ('User ' .$ this ->item ['name ' ].' was created ' );
114119
115120 if (($ user ->email ) && ($ user ->activated == '1 ' )) {
0 commit comments