Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#40342 closed enhancement (fixed)

Update name in toolbar when changing user display name

Reported by: swissspidy's profile swissspidy Owned by: adamsilverstein's profile adamsilverstein
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: Users Keywords: good-first-bug has-patch needs-testing
Focuses: ui, administration Cc:

Description

When changing the site name in Settings -> General, the name displayed in the toolbar changes automatically using JavaScript. When changing your name in your user profile, the display name choice updates as well (#5691).

Now, I think we should also update the toolbar when changing the display name. So, when I change my display name from "John" to "John Doe", the toolbar should change from "Howdy, John" to "Howdy, John Doe". Currently, this only happens after saving.

Attachments (4)

40342.patch (2.0 KB) - added by menakas 8 years ago.
Added javascript to change Greeting name when display name dropdown is changed.
40342.diff (1.1 KB) - added by maguiar 8 years ago.
Moves JS to user-profile.js and uses jQuery
40342.2.patch (1.3 KB) - added by menakas 8 years ago.
Added a check for current user id and the user id of profile that is being edited
40342.2.diff (1.6 KB) - added by maguiar 8 years ago.
Replaces .html references for .text, add a span.display_name to toolbar howdy

Download all attachments as: .zip

Change History (18)

@menakas
8 years ago

Added javascript to change Greeting name when display name dropdown is changed.

#1 @menakas
8 years ago

  • Keywords has-patch added; needs-patch removed

#2 @lukecavanagh
8 years ago

40342.patch The patch applies cleanly and fixes that issue.

#3 @swissspidy
8 years ago

It makes more sense to put this into user-profile.js in my opinion. Also, although I like using plain old JavaScript, I think we can use the JQuery functions instead of innerHTML.

@maguiar
8 years ago

Moves JS to user-profile.js and uses jQuery

#4 @maguiar
8 years ago

Agree with @swissspidy, new patch moves the logic to user-profile.js and uses jQuery since it's already there

Last edited 8 years ago by maguiar (previous) (diff)

#5 @swissspidy
8 years ago

Yeah that's much more like what I had anticipated.

The only drawback to 40342.diff is that it also changes the name when you're editing the profile of someone who's got the same name as you, because it's just a simple search & replace.

@menakas
8 years ago

Added a check for current user id and the user id of profile that is being edited

#7 @swissspidy
8 years ago

  • Milestone changed from Awaiting Review to 4.8

#8 @adamsilverstein
8 years ago

  • Owner set to adamsilverstein
  • Status changed from new to assigned

@maguiar & @menakas Thanks for your patch here!

I'm a little concerned by the use of .html() here because its content gets evaluated presenting a potential XSS vector. testing this I wasn’t able to exploit, however it would be better to replace only the inner name part with .text() which isn't evaluated, do you think that is possible? we can add an additional span wrapper in the html if you need a way to target the inner name part.

Last edited 8 years ago by adamsilverstein (previous) (diff)

@maguiar
8 years ago

Replaces .html references for .text, add a span.display_name to toolbar howdy

#9 @maguiar
8 years ago

Added 40342.2.diff which adds a span class to the howdy message, accounting for translations. Replaced .html method with .text and removed unnecessary code from the JS that is handled by the new span.

Last edited 8 years ago by maguiar (previous) (diff)

#10 @jbpaul17
8 years ago

  • Keywords needs-testing added

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


8 years ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


8 years ago

#13 @adamsilverstein
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 40657:

Users: Update name in toolbar when changing user display name.

When changing the user name in Users -> Your Profile, update the name displayed in the toolbar dynamically using JavaScript.

Props menakas, lukecavanagh, maguiar.
Fixes #40342.

This ticket was mentioned in Slack in #core by menakas. View the logs.


7 years ago

Note: See TracTickets for help on using tickets.