[wp-trac] [WordPress Trac] #39370: wp_insert_user() appends suffix to nicename when updating already existing user
WordPress Trac
noreply at wordpress.org
Tue Jun 24 05:41:01 UTC 2025
#39370: wp_insert_user() appends suffix to nicename when updating already existing
user
-------------------------------------------------+-------------------------
Reporter: alfhen | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
| Release
Component: Users | Version: 4.6.1
Severity: normal | Resolution:
Keywords: reporter-feedback has-patch needs- | Focuses:
unit-tests needs-test-info |
-------------------------------------------------+-------------------------
Changes (by SirLouen):
* keywords: reporter-feedback has-patch needs-testing needs-unit-tests =>
reporter-feedback has-patch needs-unit-tests needs-test-info
Comment:
== Bug Reproduction Report
=== Description
❌ This report can't validate that the issue can be reproduced.
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 137.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty 2.9
- MU Plugins: None activated
- Plugins:
* Change Username 1.0.2
* Test Reports 1.2.0
=== Testing Instructions
1. Use the code provided in supplemental artifacts somewhere you can
execute it. For example, you can create a standalone file loading `wp-
load.php` and hard-code a user id and a username and pass both to the
function.
2. Execute the code twice. First time it will set the username you
selected correctly.
3. ❌ Second time, the nicename is preserved identically
=== Actual Results
1. ❌ Issue can't be reproduced
=== Additional Notes
- The idea of @azaozz to using a plugin for changing the username was good
on paper… but obviously, if they wanted to have a functional plugin, they
would not be using this route. For example, [https://wordpress.org/plugins
/change-username/ this plugin], directly do the edits through SQL. For
this reason, I built a little plugin to mimic this job.
- Maybe this has been solved at some point? Please review the code
proposed and the steps and see if I'm missing something to report back.
- I refreshed the patch thinking that I could easily reproduce this bug,
but I couldn't. In case someone gives new testing instructions, perhaps
that patch could sort the potential problem.
=== Supplemental Artifacts
Testing base code:
{{{
function change_username( $user_id, $new_username ) {
$user_data = array(
'ID' => $user_id,
'user_login' => $new_username,
);
return wp_insert_user( $user_data );
}
$user_id = 1
$new_username = 'test-nicename'
change_username( $user_id, $new_username );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39370#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list