Associate Every Displayed User Name With Corresponding users.data Table Row Updated:

I would like data from the users.data table displayed with every "User Name" however it is displayed. 

As an example, I have this in hook_preprocess_page_title():

function hook_preprocess_page_title(&amp;$variables) {

  if (\Drupal::routeMatch()-&gt;getRouteName() == 'entity.user.canonical') {

    $gUD = \Drupal::service('user.data');
    $routeUID = \Drupal::routeMatch()-&gt;getRawParameter('user');
    $gudValue = $gUD-&gt;get('module', $routeUID, 'name');

    if ($gudValue = $moduleValue)) {
      kpr('Success!');
    }

  }

}


The route entity.user.canonical allows me to reference the viewed user, and so I can use \Drupal::routeMatch()-&gt;getRawParameter('user') to get the non-current user ID. (it's not the route that counts, but my ability to reference the users.data table for the displayed user)

And this in hook_preprocess_username():

function hook_preprocess_username(&amp;$variables) {
  $gUD = getUsersData();
  $gudValue = $gUD-&gt;get('module', $variables['uid'], 'name');
}


So what I am looking for is something like:

hook_preprocess_HOOK() {
  $UID = // From displayed user name.
  \Drupal::service('user.data')-&gt;get('module', $UID, 'name');
}


for each displayed user name.

The problem here: get user id from username or email without logging in, is that I don't know, and cannot manually enter the username value.



A couple of examples where the username is displayed on a page without using the username field:


Views field Name (not linked to user, uses views field base)
User type entity reference field (format display label, uses field base)


hook_preprocess_page_title() and hook_preprocess_username() are pretty straight-forward. And I believe I know where/when this template/hook will be used, but I am still having trouble defining a couple of other instances, and determining the best hook to alter the output as needed.
It sounds like you should start with what you don't want.

Drupal::currentUser()-&gt;id() will retrieve the current user's UID. From there, you can use the UserStorage::loadByProperties() method you referenced to pull the UID by user name. The last step is add code to check Drupal::currentUser()-&gt;id() doesn't match the UID found from UserStorage::loadByProperties()