Make WordPress Core

Opened 12 years ago

Last modified 2 weeks ago

#26962 new enhancement

in wp-admin/profile.php no restoration filled if an error occurs fields.

Reported by: quarkseo's profile QuarkSEO Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: Users Keywords: has-patch
Focuses: administration Cc:

Description

I just saw that if the fields are filled and that we delete such a required fields (or causing an error in the syntax of email for example), no mechanism is in place to restore the information specified by the user, everything is reset.
This mechanism is however in place in the "wp-admin/user-new.php" when we disable javascript.

Change History (6)

#1 @bcworkz
12 years ago

  • Keywords reporter-feedback added

I cannot replicate the same conditions. Would you please provide a 'walk through' for us to follow so we can see the same conditions?

There aren't many required fields. The username cannot be changed at all. If one deletes the nickname, it is replaced by a copy of the username, the default value. It does not revert to an old value if it was different from the default. This is the only thing that remotely resembles what you are talking about. Any invalid or blank email I try to submit does revert to the original value. The password cannot be deleted. Leaving the fields blank does not change anything. Putting in anything other than a matched string for password does not change anything. Of course a matched string changes the password to that string.

I believe that covers all the required fields. No matter what I do, I cannot cause the profile to be in an unusable state.

Last edited 12 years ago by bcworkz (previous) (diff)

#2 @QuarkSEO
12 years ago

I did a demonstration of "problem" video ..
I hope it will be enough and you will understand the problem

https://vimeo.com/85519889
password video : wordpress

#3 @bcworkz
12 years ago

  • Keywords reporter-feedback removed

Thank you for the video, I understand now and I get the same problem. For anyone that doesn't want to watch videos, the issue is when new text is entered in any field along with an erroneous email or something else that will throw an error, when the page is submitted and the error displayed, the text entered on the previous page is gone, apparently requiring the user to re-enter the data.

If one spent a lot of time composing the perfect Bio, this would be very frustrating!

If this happens to anyone before this issue can be addressed, use your browser's back button to get the text previously entered to re-appear.

#4 @SergeyBiryukov
12 years ago

  • Component changed from Administration to Users
  • Keywords needs-patch added
  • Version changed from 3.8 to 2.0

Confirmed.

edit_user() doesn't update anything if there's an error in username, e-mail, or password, so the data entered in other fields is lost. It should probably unset the ones with errors (to prevent them from being saved), but still save the others.

user-new.php just displays the values from $_POST (the user is not created yet), so the "Add New User" screen doesn't have this issue.

#5 @chriscct7
11 years ago

  • Focuses administration added

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


2 weeks ago
#6

  • Keywords has-patch added; needs-patch removed

Core Track Ticket: https://core.trac.wordpress.org/ticket/26962

Use this split version:

Problem

When a user updates their profile in /profile.php or edits another user in /user-edit.php, a validation error in fields such as email, username, or password causes the rest of the submitted changes to appear lost after the page reloads.

For example, if a user updates their first name, last name, and website, but enters an invalid email address, the form shows the error and reloads with the previously saved values instead of preserving the valid changes they submitted.

This creates an inconsistent experience compared with /user-new.php, where submitted values remain available after a validation failure.

Root Cause

In the edit-profile flow, edit_user() validates the request and returns a WP_Error as soon as validation errors are present. Since wp_update_user() is never called in that path, none of the valid fields from the submission are persisted.

After that, user-edit.php rebuilds the form using the saved user record from the database. As a result, the screen reflects old values rather than the valid data the user just submitted.

The add-user flow behaves differently because user-new.php repopulates its form directly from $_POST, which is why it does not show the same issue.

Solution

The fix allows the update flow to save valid submitted fields even when the request contains field-specific validation errors.

The implementation:

Inspects the validation errors returned by edit_user().
Identifies which submitted fields are invalid.
Removes only those invalid properties from the update payload.
Calls wp_update_user() with the remaining valid data.
Preserves the original WP_Error response so the user still sees the validation message.
This keeps WordPress’s validation behavior intact while preventing unrelated profile changes from being lost.

Note: See TracTickets for help on using tickets.