How to enforce a required tag for topic creation in a specific category via theme JS (Blackout theme)?

Hi everyone,

I want to enforce a rule in my Discourse forum where, for a specific category only, users must attach a particular tag when creating a topic. Users can attach any number of tags, but one specific tag must be present; otherwise, the topic creation should be blocked with an error message.

I’m using the Blackout theme (or custom theme), and I want to add this validation client-side with JavaScript.

Is there a way to add such a condition in the theme’s JavaScript (e.g., in the Blackout theme’s custom code) to:

  • Check if the topic being created belongs to the specific category,

  • Check if the required tag is attached,

  • Show an error and prevent topic creation if the required tag is missing?

If yes, could someone please share an example or the best approach to do this?

Thanks in advance!

I’m fairly sure you can do this with built-in tools.

In the category settings, look at:

So you just need to make a tag-group, add the tag you want, and then select that group in the category you want it to be required.

1 Like

Hi,
I followed the steps.
I created a Tag Group and added a single tag to it.

  1. In the category settings, under Tags > Required tag group, I selected this tag group.

  2. My expectation is: when creating a new topic in this category, at least one tag from the required tag group should be mandatory.

However, the system is allowing topics to be created without any tag from the required tag group, which defeats the purpose of this setting.

I’ve attached screenshots showing:

Can you please help investigate if this is a bug, or if I might be missing something?

1 Like

I think you’re right and you have uncovered a bug. I’m pinging the relevant team!

@S.AAKASH_MUTHIAH

Okay so it turns out this restriction does not apply to admins…

So at least it’s working as expected for normal users, I’ve tested it and can confirm.

We’re discussing internally how we will improve this further, either by applying it globally or making this behaviour at least clear.