Let me summarize what was said in commments and in chat.
There are a few related feature requests on Meta Stack Exchange, but my impression is that they are unlikely to get implemented: Make the “past names” list public info for 30 days after changing your name, Keep short history of user display names. (This one is also related, to some extent: Change all @username references in comments when a user changes their name?. Thanks to Federico Poloni for mentioning this post.) From these posts I understand that the moderators can see the past diplaynames. So one solution to see the older usernames would be becoming a moderator - however this is only feasible for small fraction of users.
As Todd Trimble mentioned in a comment, older usernames can appear in past replies directed at that user:
This is hit or miss, but when people ping users in comment threads, the old name after the @ doesn't change. So if you are sufficiently determined, you can try scouring old comment threads.
So if at least one comment reply in the form @username
was directed at a particular user while he had some username, the username could be obtained from this.
Comment replies from API
Stack Exchange API has a method to get all comments where the given user was mentioned. From this, usernames used in those comments could be obtained. In fact, there used to be an application on Stack Apps for this purpose: Find old display names of a user.
The link provided in that post is no longer working, but some version can be seen in Wayback Machine here and here.
I have tried to copy-paste the version from Wayback Machine and edit it a bit - and I got some working version here: http://msleziak.com/stackexchange/oldusernames/ (You can also see some screenshots in the linked chat transcript.) I was pleasantly surprised that this works also for deleted users.
I should say that I have no experience with JavaScript whatsoever, so I was basically copying some stuff without really knowing what it does. Probably there are many users around here who would be able to create a much better version from this.
Comment replies using SEDE
I have mentioned also some related posts on Mathematics Meta: To whom am I replying?, List earlier display names for an account and to some extent also Is it possible to know the name of a user with account deleted?.
You can find there some SEDE queries which check replies in posts and comments. Naturally, there will be many false positives. (In some comment which is under my post or follows my comment, people can use @username
also to notify somebody else who was involved in the conversation. But there is at least some likelihood that my username might appear in such comments quite often.) This could be useful also if you want username of a user who has deleted their account.
They are far from perfect, but you can try for yourself whether they are useful at least in some cases.
To check for some specific user, simply run this query with that user's id. (The way to find someone's userid is explained in this post on Meta Stack Exchange and this post on Mathematics Meta.) In the case of deleted user, the string user{id}
is displayed instead of username, so in that case you can see the id immediately.
(In the above links I have used the OP of this question for the first two queries and quid as an example of deleted user. Maybe some user on MO who often changes their username would be better for testing purposes - but I wasn't able to think of such user.)
Further comments
Whether you're using API or SEDE, you can try both main and meta. As users are typically more active on main than on meta, the results from main will probably be more helpful.
Both solutions basically search in comments for strings starting with @
until the end of the word. End of the word is decided in JavaScript by using regular expression /@\w+\b/
, so it ends on the metacharacter \b. In SEDE it is until the next space or characters such as :
, , ,
. or .
(colon, comma or full stop). In practice that means that it won't work on some usernames. For example, since "S. Carnahan" has a dot in his username, you will only get "S" when a comment contains @S.Carnahan
.
Another consequence of the way it works is that we get also shortenings of the username which somebody used in a comment reply. For example, if somebody responds to me, both @Martin
and @MartinSleziak
will work (and I'll get notification about such comments; more details can be found here: How do comment @replies work?). So if somebody used the shorter form, "Martin" will also appear in the list obtained by the above script. (Despite the fact that my username at the time was longer.)