I recently moved a site to Discourse. what i didn’t realise was many users usernames got changed and the new usernames seem to use a part of their email address. I have never seen usernames change during previous migrations. how can i revert this?
If you’ve gone live then it’ll be difficult to change things, though the original username should be in a user custom field. You really want to solve these problems in the testing phase.
Unless the migration script is broken, the reason that usernames are changed is that they are incompatible with the discourse username format.
What are some usernames that were changed? What did you migrate from?
Thank you for your reply Jay. We had to put the site on maintenance mode to make these corrections. it was weird that the username and name columns were changed. we are seeing how we can swap them. this is very confusing…
You can look at UserCustomField.where(user_id: some_id)
to see what custom fields exist for that user, which should include their original username.
We were able to swap. But after swapping the profiles won’t open! It’s says oops page not found.
Just to double check, you refreshed your page after remapping usernames, right? Discourse will still use old name client-side until you reload, so if you remapped names and didn’t reload, it’d try to open user profiles that no longer exist.
Thank you. We will check for that.
Also, I don’t understand how it decides to automatically assign first half of the email address.
The precious platform allowed users to create profile names using spaces and special characters, and it used userID for URL.
Can we use userID on URL and allow migration of profile names with spaces and special characters as is?
We saw that sims usernames and names were the same.
We realised some names now contain spaces.
If we swap username and name sections, then discourse might assign half email ID as username for the ones that don’t comply with profile name guidelines.
And why would discourse use email addresses in the first place? Security risk
No. Discourse does not allow spaces or (most) special characters in usernames. That’s why they got re-written.
I don’t understand what you’re saying about URL.
It has to use something to generate a username.
It does this:
UserNameSuggester.suggest(
opts[:username].presence || opts[:name].presence || opts[:email],
So if you don’t have a username or a name it falls back to using the first part of the email address.
So we can change it to something else? or remove email ID as an option?