Reserved usernames programmably?

Hi guys,
Is it possible to manage ‘reserved usernames’ programmably?
I understand that there is that thing called rails console - would that be where a novice should jump to right away, If it can be done there?
Or else - how do you add many long words to your reserved usernames? Thanks.

I believe this can be done in the rails console and I think I have an idea of how. But if you are new to working in rails console and are unfamiliar with it, I would suggest learning a bit more about it before doing something like this. Mistakes in rails console can break your forum. For what it’s worth, likely better off doing it manually in the admin UI.

1 Like

webui will not work for me - I don’t mind broken things, that is what labs are for.

If you’re not familiar with rails, you can Reverse engineer the Discourse API and do it with curl or similar.

1 Like

Yes, I did this once for a site that had a huge list of reserved usernames. As long as you are aware of the risks of using the Rails console, you can enter it by going to the /discourse directory in your server and running:

./launcher enter app
rails c

From the prompt that appears, run:

SiteSetting.reserved_usernames

You should see output similar to this:

"admin|moderator|administrator|mod|sys|system|community|info|you|name|username|user|nickname|discourse|discourseorg|discourseforum|support|all|here"

That’s the setting’s default value. You will probably want to add the default list to your custom list. Make sure that the entire list is surrounded by quotation marks, with each item separated by a pipe character (|)

Then run:

SiteSetting.reserved_usernames="your|reserved|usernames"

Replace your|reserved|username with your actual list of usernames.

Exit the Rails console by typing exit at the prompt.

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.