A user, pablogg, deleted a user with a certain username but is unable to reuse the same username for another user, receiving the message “Username has to be unique.” Canapin suggests checking if the username is taken or not completely deleted using the admin panel or the Data Explorer plugin.
After attempting these methods and finding no results, Canapin shares the code that checks if a username is already taken, which includes a check for both users and groups. He speculates that the issue might be due to a reserved username or a group with the same name.
codinghorror also suggests that the issue could be due to a group with the same name, as users and groups share a namespace. However, pablogg confirms that there is no group with the same name. Additionally, pablogg notes that they can still mention the deleted username in direct messages.
I have deleted a user with username = “XXX” and I want yo change the username of other user with the same username of deleted user but I can not. I get the mensagges. “Username have to be unique”
How can I check if a username is taken or not complete deleted?
I don’t know. What is the username you’re trying to use?
Maybe you try a reserved username, but I guess you’d have a different message…
Also the previous user woudn’t have been able to choose it
Here’s the code that checks if a username is already taken:
USERNAME_EXISTS_SQL = <<~SQL
(SELECT users.id AS id, true as is_user FROM users
WHERE users.username_lower = :username)
UNION ALL
(SELECT groups.id, false as is_user FROM groups
WHERE lower(groups.name) = :username)
SQL
Any deleted user?
edit: I tried to rename a user the same name as a group, and it says the username must be unique. Maybe that’s your issue?