Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
[user] is replaced with $account->name. This makes it difficult when trying to output all user names the same way by overriding theme_username().
Is there a reason that this line:
$values['user'] = $account->uid ? check_plain($account->name) : variable_get('anonymous', 'Anonymous');
Cannot be replaced with this line?
$values['user'] = theme('username', $account);
This would be a lot more consistent with how user names are output. If this change is not acceptable, then perhaps we could introduce a new token that does call the proper theme function.
Comment | File | Size | Author |
---|---|---|---|
#17 | theme_username_token-698242-17.patch | 1.26 KB | mstef |
Comments
Comment #1
robby.smith CreditAttribution: robby.smith commented+1 subscribing
Comment #2
Dave ReidHmm...not even the core D7 tokens are using format_username. :/
Comment #3
Dave ReidFiled core issue at #734878: [user:name] tokens should be using format_username() and use [user:name-raw] in email templates, could use a review & RTBC.
Comment #4
robby.smith CreditAttribution: robby.smith commentedI was wondering if the patch will be available for Drupal 6 as well?
Thank you
Comment #5
Dave ReidWell how is this supposed to handle theme_username when it returns HTML?
Comment #6
Dave Reid#5 still needs an answer
Comment #7
robby.smith CreditAttribution: robby.smith commentedI looked around and the below is how it was done in the Mail Editor module.
http://drupal.org/node/792244#comment-2973904
Comment #8
robby.smith CreditAttribution: robby.smith commentedComment #9
ckngI'm working on D7 Submitted By module and found that there is no way to have a $submitted with a linked user name, like we normally have for content and comment.
There should be 2 additional tokens through theme('username'), IMO:
- plain strip tags, [node:author:name_themed_plain]
- fully themed (with link, etc), [node:author:name_themed]
Comment #10
Dave Reid@ckng: That's a much different issue. Please file a new issue.
Comment #11
ckng@Dave: I think it end up as the same issue, just that I've put it to my use case.
I would suggest
[user:name]
to remain as output from format_username().It is essentially adding
[user:name_themed]
and[user:name_themed_plain]
through theme('username'), that get propagated as[node:author:name_themed]
&[node:author:name_themed_plain]
, respectively.The name is a bit long though, any suggestion?
I've put together a quick patch, see attached.
Comment #12
Dave ReidSo in other words, it's a new token from what is being discussed here, and hence a feature request. Using theme_username() in the D6 token would still try to output as plain text. Please file a new issue.
Comment #13
Dave ReidThere is also no need for a user:name_themed_plain ... that's what user:name is for.
Comment #14
mstef CreditAttribution: mstef commented#11 shows the new tokens available but they're not getting populated for me.
Comment #15
mstef CreditAttribution: mstef commentedI can still see a need for this. It will run theme_username() and strip the tags. Could easily be different than $user->name.
Comment #16
mstef CreditAttribution: mstef commentedLooks like the patch is adding to the switch for taxonomy tokens.
Comment #17
mstef CreditAttribution: mstef commentedUpdated patch:
Comment #18
mstef CreditAttribution: mstef commentedSorry for so many comments..
Comment #19
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 6 year old patch in #17 to token.tokens.inc applied cleanly to the latest token 7.x-1.x-dev and if applicable still needs review.