Limit category selections for topics based on tag restrictions

AI-generated summary

Limit category selections for topics based on tag restrictions

jlc is requesting a feature to restrict category selections when creating a topic from a specific tag path, if the tag is restricted to a certain category. Currently, all categories are shown, and an error message appears when trying to save the topic. The user suggests adjusting the error message to “Please remove the tag or select a different category.”

Frully replies that while they cannot assist with coding the feature, the error message can be customized in the admin panel (Admin > Customize > Text > Search). They provide a screenshot and instructions on how to change the text.

jlc thanks Frully for the tip and acknowledges that they had forgotten about the ease of customizing text in Discourse.

I have a tag named “category-specific” that should only be used within the category named “target-category”. I have added the “category-specific” tag to the “Restrict these tags to this category” list for “target-category”. When I create a new topic from the /tag/category-specific path, all categories are shown as possibilities in the category selector, and the default selected category is the “General” category. If I try to save the topic in this state, Discourse does refuse to save the topic, indicating an error with associating that tag with that topic. Would it be possible to restrict the category selector to only those categories that allow the chosen tag?

Also, the full error message is: The “category-specific” tag cannot be used in the “General” category. Please remove it. Could we adjust that to say something like “Please remove the tag or select a different category.”?

This could be a feature request, a bug report, or a support request (i.e. I might be doing it wrong), but I’ve started it out as a feature request; I’m happy to see it migrate elsewhere if it fits better there!

I can’t help with any coding that would help force the user to change their post location - but you can definitely change the warning text, as with all text on the site:
Admin > Customize > Text > Search
https://your-forum-fqdn/admin/customize/site_texts?q=category.%20Please%20remove%20it.

Change to whatever //please remove it or change category//

1 Like

Wow, I totally forgot that you can do this so easily with Discourse. Thanks!