Is there a token that will not use the altered version of the theme_username? I didn't see anything. Seems like if a username is altered, there are many situations where you might want to still use the original value of the username. Is there a way around this?


Rob230’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev

This seems like quite an oversight. I encountered it when I had used hook_username_alter. This is because theme_username uses template_preprocess_username, which calls format_username, which calls hook_username_alter.

That all makes sense from the point of view of anywhere that the username is displayed to the user, and I can understand why you'd want that to be the case for the username token for the majority of situations. But there should be a way to access the raw username as a token.

The use case I stumbled upon was in welcome emails and forgotten password emails. By default they tell the user what the username to log in with is, but because I had used hook_username_alter it wasn't putting the raw username in the email and there is no token for it. The same would be true if you overrode theme_username.

I imagine similar problems could happen with webform if you wanted to have the raw username as a hidden field, but instead you'd get the themed one, which might not be what you want saved.

There needs to be a way to access the raw username as well as the themed/formatted one. I don't know if that is an issue for Token or Drupal core.

Fabien Crépin’s picture

Any idea on how to achieve this ? Same need for me (and here too :