diff --git a/src/Form/UwAddUsersForm.php b/src/Form/UwAddUsersForm.php
index 4ecd37ef847ec4ed5a87453c6344c5e699e37e94..54204209f482437d9740dc4555df0e6482c27b93 100644
--- a/src/Form/UwAddUsersForm.php
+++ b/src/Form/UwAddUsersForm.php
@@ -111,11 +111,12 @@ class UwAddUsersForm extends FormBase {
         continue;
       }
 
+      /** @var UserInterface $existing_user */
       $existing_user = user_load_by_name($user);
       if ($existing_user) {
         $this->messenger()->addError($this->t('The user ID <a href="@link"><em>@user</em></a> already exists and was skipped.',
           [
-            '@link' => $this->pathAliasManager->getAliasByPath('/user/' . $existing_user->uid->value),
+            '@link' => $this->pathAliasManager->getAliasByPath('/user/' . $existing_user->id),
             '@user' => $user,
           ]
         ));
@@ -163,7 +164,7 @@ class UwAddUsersForm extends FormBase {
 
       $this->messenger()->addStatus($this->t('Created a new user with the user ID <a href="@link"><em>@user</em></a>.',
         [
-          '@link' => $this->pathAliasManager->getAliasByPath('/user/' . $new_user->uid->value),
+          '@link' => $this->pathAliasManager->getAliasByPath('/user/' . $new_user->id()),
           '@user' => $user,
         ]
       ));