User cannot create a new topic and tag it during creation - The tags are not listed

I have a regular user that is trust_level_0 and trust_level_1 , and I have these settings:

tag topic allowed groups: admins, moderators, staff, trust_level_0
create topic allowed groups: admins, moderators, trust_level_1
create tag allowed groups: admins, moderators, staff

The user can create the topics, but he can not use tags when he is creating the topic. He can use the tags for search but the tags are not listed when creating a topic.

Is my setting incorrect? Am I missing something? Whit staff or admin user I can do both at once. Thanks for any advice.

2 Likes

It has caught more than a few people out, but admin and mods can skip a lot of the restrictions that apply to everyone else.

Do you have any other restrictions placed on your tags? Like a tag group that only x group can use, or any restrictions you’ve placed on tags in a particular category?

If you go to a tag page and click the tag wrench (:information_source: for non-staff) it should show you some more information that may be able to help track any extra limitations you’ve placed on it. Eg broken here on meta:

2 Likes

could be possible that Discourse is not handling the mix between trust_level_0 and trust_level_1 when creating the topic and tagging it?

Should I add trust_level_1 to this:

and add trust_level_0 in this line :

Anyone that is in trust_level_1 is also in trust_level_0 by default.

3 Likes

You may want to allow TL0 to be able to create topics, depending on your site setup, as people will often sign up to ask a question, etc and could be confused as to why they can’t (possibly giving up before figuring it out).

But I don’t think this would explain the problem you’re having.

Is this issue happening for just this user? Are other people able to successfully tag topics?

Could you give any more detail about how you’ve set your tags up?

As @HAWK said, anyone that is in trust_level_one is by default in trust_level_0, and for that reason it’s confusing for me. There are more than one user with this problem.I checked tags that can be used in the Categories that we need.

@JammyDodger , what could be interesting to check in my tags set up?

1 Like

Tags are pretty flexible and can be configured in lots of different ways so we may need some more detail on how you’ve set yours up to provide more specific suggestions.

Though a common one is when a category has been set up to have certain tags only allowed to be used in that category and the ‘also allow other tags’ hasn’t been checked. That could limit the category to only the restricted tags and if those ones are staff-only this could prevent anyone else from using any other tags.

Just to follow up (though hopefully you’ve already managed to track it down :crossed_fingers:), but Moin gave a thorough troubleshooting post for a similar thing here:

2 Likes

Hey @JammyDodger. I’ve been tangled with other issues at work but I’m still stuck with this. Z

Ok, I have my Categories, and in the “Tags” settings of the category I hav:

Restrict these tag GROUPS to this category: TAG-GRP1, TAG-GRP2

When I go to “Manage Tag Groups” I have:

TAG-GRP1:

Name: TAG-GRP1
Tags in this group:  A LIST OF MY TAGS FOR TAG-GRP1
Parent tag: -
Limit one tag per topic from this group (unchecked)

TAG-GRP2:

Name: TAG-GRP2
Tags in this group:  A LIST OF MY TAGS FOR TAG-GRP2
Parent tag: -
Limit one tag per topic from this group (unchecked)

Tags are visible only to the following groups: admin, moderators, trust_level_0, trust_level_1

And when I check as Admin the tag that I want to use when creating a topic I can see this:

This tag belongs to these groups: . It can only be used in these categories: TAG-GRP1, TAG-GRP2

I already have TL0 and TL1 in “tag topic allowed groups” and “create topic allowed groups”. But with a regular user TL1 I can not use some tags.

Did you manage to check out the troubleshooting post I linked above yet? It’s pretty thorough and could help point you in the right direction.

I’m not sure you’ve copied that over accurately?

Just as an extra FYI, there’s no need to put both TL0 and TL1 in any settings as all members of TL1 are also TL0 (think of TL0 as ‘all registered users’). Adding only TL0 would suffice. :+1:

2 Likes

Checking out your recomended link. Thanks.

1 Like

Hello @JammyDodger , Thanks for the link you posted, I thought it could help me. I already checked the link and I think my settings are fine, the recommendation in that post make sense to me, and my settings are as recomended and I enabled for test the Also allow other tags in Category settings but unfortunately it did not solve my problem.

I wonder if I need to restart “something” when permissions settings change.

First, let me excuse for sharing this image with all the text blocked, I hope you can understand.

Those are the TAG name, the tag gruops name and categories where it’s supposed to be used but I can not use with my regular user. I would like to know if it is normal to have a padlock icon close to each category name.

Thank you guys for all of your help and ideas.

It’s normal when the category is not visible to everyone.
For example, this is one of my tags. You can see that there is a lock next to “Test”


And these are the security settings of that category:

“Everyone” has no “see” permission, that’s why the lock icon is shown next to the category badge. It indicates that this category is not public.

Might this have something to do with the problem I described?

In so much as that if the user can’t access the category then they won’t be able to select it when creating a topic (and if they can’t choose it when creating a topic then your ‘allowed tag’ structure also won’t kick in). Is the user a part of a group who can access those categories?

I think if you’ve not landed on what the conflict is yet you may need to start removing some of the tag restrictions and see if you can narrow down exactly where the permission conflict is happening.

Do you have the Data Explorer plugin installed? I created a query that shows me all the limitations for a tag. Maybe that helps you too. You could perhaps even share the results and replace tag group names, tag names, and category names with other words in the output. Then it’s a little easier to help you than comparing black boxes.

Thank you @Moin . Yes, I do. I have Data Explorer plugin installed. Sorry for late reply again.

This is the query that helped me to spot the problem in my configuration. It has been some time since I used it, so I don’t remember if there was something I thought about improving.

You can filter by tag or tag group

-- [params]
-- null string :tag_name
-- null string :tag_group

WITH allowed_tags AS (
  SELECT ct.category_id, t.id AS tag_id
  FROM category_tags ct
  JOIN tags t ON t.id = ct.tag_id
  UNION
  SELECT ctg.category_id, tgm.tag_id
  FROM category_tag_groups ctg
  JOIN tag_group_memberships tgm ON tgm.tag_group_id = ctg.tag_group_id
),

restricted_categories AS (
  SELECT c.id, c.name
  FROM categories c
  WHERE c.allow_global_tags = FALSE
    AND (
      EXISTS (SELECT 1 FROM category_tags ct WHERE ct.category_id = c.id)
      OR EXISTS (SELECT 1 FROM category_tag_groups ctg WHERE ctg.category_id = c.id)
    )
),

all_tag_category_combinations AS (
  SELECT t.id AS tag_id, t.name AS tag_name, rc.id AS category_id, rc.name AS category_name
  FROM tags t
  CROSS JOIN restricted_categories rc
  WHERE t.target_tag_id IS NULL
),

not_allowed_tags AS (
  SELECT atcc.tag_id, atcc.category_id, atcc.category_name
  FROM all_tag_category_combinations atcc
  LEFT JOIN allowed_tags al
    ON al.tag_id = atcc.tag_id AND al.category_id = atcc.category_id
  WHERE al.tag_id IS NULL
)

SELECT
  main.id AS tag_id,
  main.name AS tag_name,
  COALESCE(STRING_AGG(DISTINCT syn.name, ', '), '') AS synonyms,

  tg.id AS tag_group_id,
  COALESCE(parent_tag.name, '') AS parent_tag_name,  
  CASE WHEN tg.one_per_topic THEN 'true' ELSE '' END AS one_tag_per_topic,

  COALESCE(
    STRING_AGG(
      DISTINCT
      CASE
        WHEN crtg.min_count IS NOT NULL THEN crtg_cat.name || ' (' || crtg.min_count || ')'
        ELSE NULL
      END,
      ', '
    ),
    ''
  ) AS required_in_categories_with_min,

  COALESCE(STRING_AGG(DISTINCT ctg_cat.name, ', '), '') AS tag_group_limited_to_category,
  COALESCE(STRING_AGG(DISTINCT ctags_cat.name, ', '), '') AS tag_limited_to_category,
  COALESCE(STRING_AGG(DISTINCT nat.category_name, ', '), '') AS not_allowed_in_categories,

  CASE 
    WHEN COUNT(DISTINCT g.name) > 0 THEN COALESCE(STRING_AGG(DISTINCT g_use.name, ', '), '')
    ELSE ''
  END AS use_limited_to,
  COALESCE(STRING_AGG(DISTINCT g.name, ', '), '') AS view_only_groups

FROM tags AS main
LEFT JOIN tags AS syn ON syn.target_tag_id = main.id
LEFT JOIN tag_group_memberships AS tgm ON tgm.tag_id = main.id
LEFT JOIN tag_groups AS tg ON tg.id = tgm.tag_group_id
LEFT JOIN tags AS parent_tag ON parent_tag.id = tg.parent_tag_id
LEFT JOIN tag_group_permissions tgp ON tgp.tag_group_id = tg.id AND tgp.permission_type = 3
LEFT JOIN groups g ON g.id = tgp.group_id

LEFT JOIN category_required_tag_groups AS crtg ON crtg.tag_group_id = tg.id
LEFT JOIN categories AS crtg_cat ON crtg.category_id = crtg_cat.id
LEFT JOIN category_tag_groups AS ctg ON ctg.tag_group_id = tg.id
LEFT JOIN categories AS ctg_cat ON ctg.category_id = ctg_cat.id
LEFT JOIN category_tags AS ctags ON ctags.tag_id = main.id
LEFT JOIN categories AS ctags_cat ON ctags.category_id = ctags_cat.id
LEFT JOIN not_allowed_tags AS nat ON nat.tag_id = main.id
LEFT JOIN tag_group_permissions tgp_use ON tgp_use.tag_group_id = tg.id AND tgp_use.permission_type = 1
LEFT JOIN groups g_use ON g_use.id = tgp_use.group_id

WHERE
  main.target_tag_id IS NULL AND
  (
    :tag_name IS NULL OR
    LOWER(main.name) LIKE LOWER('%' || :tag_name || '%') OR
    LOWER(syn.name) LIKE LOWER('%' || :tag_name || '%')
  ) AND
  (
    :tag_group IS NULL OR
    LOWER(tg.name) LIKE LOWER('%' || :tag_group || '%')
  )

GROUP BY
  main.id, main.name, tg.id, tg.name, parent_tag.name, tg.one_per_topic
ORDER BY main.name, tag_group_id

@Moin, I tried the query in version 3.5.0.beta8-dev and it did not work. I got this error messge:

PG::QueryCanceled: ERROR:  canceling statement due to statement timeout

I Google this error and I found that I should increase statement_timeout but this is happening in a production server and I don’t know too much about DBs, PostgreSQL. I am seeing how to make it work without screwing up the server.

Just for curious I tried the query with a friend in other forum running version 3.4.0.beta1-dev and the script ran without any issues and looks like it worked fine.

thanks for your time and advices.