Make WordPress Core

Opened 8 months ago

Last modified 4 days ago

#61469 new defect (bug)

Display name doesn't update correctly when first and last name fields are cleared.

Reported by: lekiq's profile lekiq Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.5.4
Component: Users Keywords: has-testing-info has-patch
Focuses: privacy Cc:

Description

When a user fills out the "First Name" and "Last Name" fields in their profile and selects a display name option, the display name reflects the first and last names correctly. However, if the user later removes the values from the "First Name" and "Last Name" fields, the display name still displays the previously entered first and last names. The display name only updates correctly if the user also changes the "Display name publicly as" field. This behavior can be confusing and inconsistent.

Steps to Reproduce:

  1. Go to the profile editing page.
  2. Enter values in the "First Name" and "Last Name" fields.
  3. Select a display name option that includes the first and last names.
  4. Save the changes.
  5. Remove the values from the "First Name" and "Last Name" fields.
  6. Observe that the display name still shows the previously entered first and last names.
  7. Change the "Display name publicly as" field to any other option and then back to the desired option.
  8. Save the changes.
  9. Observe that the display name now updates correctly.

Expected Behavior:
The display name should automatically update to reflect the cleared "First Name" and "Last Name" fields without requiring additional changes to the "Display name publicly as" field.

Actual Behavior:
The display name does not update and still shows the previous first and last names unless the "Display name publicly as" field is manually changed.

Change History (5)

#1 @sudipatel007
8 months ago

  • Keywords needs-patch has-testing-info added

I can reproduce the same issue - https://www.loom.com/share/7b471840227e4f6e8b6f129b38843bd3

Environment

  • WordPress: 6.6-beta2-58420
  • PHP: 8.1.23
  • Server: nginx/1.16.0
  • Database: mysqli (Server: 8.0.16 / Client: mysqlnd 8.1.23)
  • Browser: Chrome 126.0.0.0 (macOS)
  • Theme: Twenty Nineteen 2.8

This ticket was mentioned in PR #6911 on WordPress/wordpress-develop by @khokansardar.


8 months ago
#2

  • Keywords has-patch added; needs-patch removed

On removing the values from the "First Name" and "Last Name" fields observe that the display name still shows the previously entered first and last names in edit user.
This PR fix this issue.

Trac ticket: #61469

This ticket was mentioned in PR #6911 on WordPress/wordpress-develop by @khokansardar.


8 months ago
#3

On removing the values from the "First Name" and "Last Name" fields observe that the display name still shows the previously entered first and last names in edit user.
This PR fix this issue.

Trac ticket: #61469

#4 @sudipatel007
7 months ago

  • Keywords needs-patch added; has-patch removed

Test Report

I have tested with this patch but still it is not working.
https://github.com/WordPress/wordpress-develop/pull/6911.diff

Environment

  • WordPress: 6.6-beta2-58420
  • PHP: 8.1.23
  • Server: nginx/1.16.0
  • Database: mysqli (Server: 8.0.16 / Client: mysqlnd 8.1.23)
  • Browser: Chrome 126.0.0.0 (macOS)
  • Theme: Twenty Nineteen 2.8

This ticket was mentioned in PR #8259 on WordPress/wordpress-develop by @sahilgidwani.


4 days ago
#5

  • Keywords has-patch added; needs-patch removed

This pull request addresses the issue where the display name does not correctly update when the "First Name" and "Last Name" fields are cleared in the user profile. The behavior was inconsistent, and the display name would still show the previously entered first and last names unless the "Display name publicly as" field was manually modified.

### Problem:

  • When users enter a first and last name and select a display name option that includes those values, the display name updates as expected.
  • However, when the user clears the "First Name" and "Last Name" fields, the display name still reflects the previously entered names.
  • The display name only updates correctly if the user manually changes the "Display name publicly as" field.

### Solution:

  • Updated the logic in the user profile form to automatically update the display name based on the current values in the "First Name" and "Last Name" fields.
  • Added a fallback mechanism where the display name will revert to the user login if the first and last names are removed or empty.
  • Implemented dynamic changes to the display name dropdown, ensuring it updates when the "First Name" or "Last Name" fields are modified or cleared.

### Changes:

  • Modified the PHP logic that handles the display name options to ensure that when the first and last name fields are cleared, the display name correctly reflects the changes without needing to manually adjust the "Display name publicly as" field.
  • Adjusted JavaScript to ensure the admin toolbar greeting (Howdy, * in the admin bar) is updated dynamically based on changes made to the display name in the profile form.


### Expected Behavior:

  • When a user clears the "First Name" and "Last Name" fields, the display name should update automatically to reflect these changes without needing any further interaction with the "Display name publicly as" dropdown.
  • The admin toolbar greeting ("Howdy, *") will also update accordingly when the display name is changed.

This change ensures a smoother user experience when editing the profile, especially when clearing first and last name fields.

Let me know if you need anything further!

https://github.com/user-attachments/assets/045c97de-2a85-4737-8aed-2073b42ddaf6

Note: See TracTickets for help on using tickets.