Reserved usernames programmably?

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