Bug: nicename not created/updated
-
I found I bug with users in 1.2.
If you create a new user through the admin interface, the user_nicename is created correctly. However, if you create a new user with the wp-registration.php page, the nicename is left blank. In wp-registration.php, find this line (around line 85):
$user_nickname = $wpdb->escape($user_nickname);
Right after that, add this line:
$user_nicename = sanitize_title($user_nickname);
The query (a few lines below) must be changed from:
$result = $wpdb->query("INSERT INTO $tableusers
(user_login, user_pass, user_nickname, user_email, user_ip, user_browser, dateYMDhour, user_level, user_idmode)
VALUES
('$user_login', MD5('$pass1'), '$user_nickname', '$user_email', '$user_ip', '$user_browser', '$now', '$new_users_can_blog', 'nickname')");
to:
$result = $wpdb->query("INSERT INTO $tableusers
(user_login, user_pass, user_nickname, user_email, user_ip, user_browser, dateYMDhour, user_level, user_idmode, user_nicename)
VALUES
('$user_login', MD5('$pass1'), '$user_nickname', '$user_email', '$user_ip', '$user_browser', '$now', '$new_users_can_blog', 'nickname', '$user_nicename')");
There is a similar issue with profile.php in the admin area. If you change your nickname, your nicename should be changed accordingly (or is it a bad idea?). So, in wp-admin/profile.php, find this line (88 or so):
$newuser_nickname=addslashes(stripslashes($_POST['newuser_nickname']));
Right after that, add this line:
$newuser_nicename=sanitize_title($newuser_nickname);
And the query a few lines below becomes:
$query = "UPDATE $tableusers SET user_firstname='$newuser_firstname', $updatepassword user_lastname='$newuser_lastname', user_nickname='$newuser_nickname', user_icq='$newuser_icq', user_email='$newuser_email', user_url='$newuser_url', user_aim='$newuser_aim', user_msn='$newuser_msn', user_yim='$newuser_yim', user_idmode='$newuser_idmode', user_description = '$user_description', user_nicename = '$newuser_nicename' WHERE ID = $user_ID";
The changes above fix the problem where the wp_list_authors() function with ‘robot-friendly’ permalinks enabled would output incorrect links (https://blog.com/archives/author// instead of https://blog.com/archives/author/me/) for users created through wp-registration.php because their nicename is empty.
- The topic ‘Bug: nicename not created/updated’ is closed to new replies.