# Reserved usernames programmably?

**URL:** https://meta.discourse.org/t/reserved-usernames-programmably/278906
**Category:** Support
**Created:** [September 13, 2023, 5:05pm UTC](https://meta.discourse.org/t/reserved-usernames-programmably/278906 "2023-09-13T17:05:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![lejeczek](https://avatars.discourse-cdn.com/v4/letter/l/edb3f5/32.png) [@lejeczek](https://meta.discourse.org/u/lejeczek)
#### Post date: [September 13, 2023, 5:05pm UTC](https://meta.discourse.org/t/reserved-usernames-programmably/278906/1 "2023-09-13T17:05:56Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [September 13, 2023, 5:23pm UTC](https://meta.discourse.org/t/reserved-usernames-programmably/278906/2 "2023-09-13T17:23:25Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![lejeczek](https://avatars.discourse-cdn.com/v4/letter/l/edb3f5/32.png) [@lejeczek](https://meta.discourse.org/u/lejeczek)
#### Post date: [September 13, 2023, 5:34pm UTC](https://meta.discourse.org/t/reserved-usernames-programmably/278906/3 "2023-09-13T17:34:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 13, 2023, 11:28pm UTC](https://meta.discourse.org/t/reserved-usernames-programmably/278906/4 "2023-09-13T23:28:53Z")

</div>

If you’re not familiar with rails, you can [Reverse engineer the Discourse API](https://meta.discourse.org/t/reverse-engineer-the-discourse-api/20576) and do it with `curl` or similar.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [September 14, 2023, 1:35am UTC](https://meta.discourse.org/t/reserved-usernames-programmably/278906/5 "2023-09-14T01:35:21Z")

</div>

> [@lejeczek](#):
>
> Is it possible to manage ‘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:

```plaintext
./launcher enter app
rails c

```

From the prompt that appears, run:

```plaintext
SiteSetting.reserved_usernames

```

You should see output similar to this:

```plaintext
"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:

```plaintext
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.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 14, 2023, 1:36am UTC](https://meta.discourse.org/t/reserved-usernames-programmably/278906/6 "2023-10-14T01:36:16Z")

</div>

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