Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Needs review
FileSize
689 bytes

Simple patch for review.

Dave Reid’s picture

Assigned: Unassigned » Dave Reid
awmckinley’s picture

Patch works great. Made a quick module containing a simple hook_username_alter(), and the change showed up in a pathauto generated URL alias.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Patch works fine.

Can someone explain why theme_username does not use format_username to get the name?

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Straight-forward fix. Committed to HEAD. Thanks!

dawehner’s picture

preprocess_username users format_username already.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Alan D.’s picture

Version: 7.x-dev » 8.x-dev
Status: Closed (fixed) » Needs review
FileSize
5.28 KB

With this patch, we lose the ability to access the username in user emails, etc.

I would suggest providing the user-raw token that the RealName module provides into core, otherwise every implementation of hook_username_alter() will need to provide their own tokens.

dawehner’s picture

With this patch, we lose the ability to access the username in user emails

Maybe it's not obvious for me, but can you eloberate why?

Alan D.’s picture

Because the token [user:name] uses $account->name run through format_username() that invokes hook_username_alter().

For example, the Name module also implements this. This provides a multi-component name field and unlimited formatting options. We were using this, with the format "First name Surname" and the resulting emails sent using the user email templates were giving "username: Mr John Doe" rather then "username: johndoe"

tstoeckler’s picture

We could also have an extra layer of nesting:
[user:name:formatted]
[user:name:raw]
The former would be the default and would be implied when doing [user:name].
What do you guys think?

tim.plunkett’s picture

Issue tags: +Needs backport to D7

Fixing tag

hass’s picture

Title: [user:name] tokens should be using format_username() » [user:name] tokens should be using format_username() and use [user:name-raw] in email templates

Looks like this is the core case for #1827980: Post module enable/disable requirements (README): Account settings - E-mails require manual update, isn't it?

Are we able to get this in and change all username tokens in email templates to name-raw, please?

hass’s picture

Status: Needs review » Needs work
Issue tags: +token, +Needs backport to D7

The last submitted patch, drupal-raw-username-token-734878-8.patch, failed testing.

Alan D.’s picture

Status: Needs work » Needs review
FileSize
5.49 KB

re-roll

Xano’s picture

scor’s picture

reroll after a file move.

Berdir’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Looks good to me and makes sense, but I think we won't be able to get this in without tests...

Optimal case would be a registration test that enables a user name alter module and then check the sent e-mail.

mgifford’s picture

Version: 8.0.x-dev » 8.1.x-dev
Assigned: Dave Reid » Unassigned

This still a concern in D8? Unassigned issue too.

Berdir’s picture

Status: Needs work » Closed (duplicate)
Alan D.’s picture

Version: 8.1.x-dev » 7.x-dev
Status: Closed (duplicate) » Needs work

D8
[user:display-name]
[user:name]

But still broken on D7 and that patch isn't back-portable ;)

  • webchick committed 1ba21f9 on 8.3.x
    #734878 by Dave Reid: Fixed [user:name] tokens should be using...

  • webchick committed 1ba21f9 on 8.3.x
    #734878 by Dave Reid: Fixed [user:name] tokens should be using...

  • webchick committed 1ba21f9 on 8.4.x
    #734878 by Dave Reid: Fixed [user:name] tokens should be using...

  • webchick committed 1ba21f9 on 8.4.x
    #734878 by Dave Reid: Fixed [user:name] tokens should be using...

  • webchick committed 1ba21f9 on 9.1.x
    #734878 by Dave Reid: Fixed [user:name] tokens should be using...