#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 |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.4 |
| Component: | Users | Version: | 4.0 |
| Severity: | normal | Keywords: | has-patch needs-refresh |
| Cc: | Focuses: |
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
@
12 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
@
11 years ago
- Keywords commit added
- Milestone Awaiting Review → 4.4
- Owner set to
- Status new → accepted
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Attached is a patch, with tests, that implements this behaviour.