Drupal 8.x
I am currently using hook_preprocess_user().
I would like to alter the username to add some custom markup to every username.
MYMODULE.module:
function MYMODULE_preprocess_user(&$variables) {
$variables['elements']['#user']->name->value = t('Name @newMarkup', ['@newMarkup' => ' Hello']);
}
This returns Name Hello Hello
. Concatenation adds 'Hello' twice so this approach is not working.
I've also worked with user_format_name_alter(&$name, $account), however, this does not seem to fit my use case.
How can I alter the username text? Not looking for a "currentUser" solution, but every user so names are changed everywhere. Reference, Views, etc.
/admin/structure/views/view/view_name
and a views page, it appears to render ok. I have been testing via a referenced views block.