#29880 closed defect (bug) (fixed)
wp_insert_user() wiping out user_pass when one isn't provided and the user exists
Reported by: | cartpauj | Owned by: | chriscct7 |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.0 |
Component: | Users | Keywords: | has-patch needs-refresh |
Focuses: | Cc: |
Description
This is similar to #21495 but not identical.
Passing wp_insert_user() the following for example, will cause the Users password to be nullified if the user already exists:
array(6) { ["role"]=> string(10) "subscriber" ["user_login"]=> string(15) "test" ["user_email"]=> string(15) "test@example.com" ["first_name"]=> string(3) "John" ["last_name"]=> string(3) "Doe" ["ID"]=> int(123) }
I propose changing (found here: http://cspf.co/XvqW)
$user_pass = $userdata['user_pass'];
to this or something similar
$user_pass = (isset($userdata['user_pass']) && !empty($userdata['user_pass']))?$userdata['user_pass']:$old_user_data->user_pass;
Attachments (3)
Change History (11)
#3
@
10 years ago
Hi Sergey,
Thanks for your comment - in that case perhaps deprecating the use case of passing a user ID is the better solution here. Patch attached.
#4
@
9 years ago
- Keywords commit added
- Milestone changed from Awaiting Review to 4.4
- Owner set to chriscct7
- Status changed from new to accepted
Note: See
TracTickets for help on using
tickets.
Attached is a patch, with tests, that implements this behaviour.