Does an action fire when adding a tag via the “Tags” meta box?

When a user adds a tag to a post, I’m trying to determine if they have permission to post in to that specific tag. If the user is not assigned to a tag that they try adding via the input in the “Tags” meta box, I’d like to display an error along the lines of “you do not have permission to post in $tag_name.`

I know there are hooks for create_tag, but that doesn’t fire until you actually save the post, because the tag doesn’t get created until the post is saved. For exiting tags, it looks like set_object_terms could be useful, but again, that doesn’t get fired until you actually save the post.

Does any filter exist when a user enters a tag in the input on in Tags meta meta box, after clicking “add”?

1 Answer
1

try to use undocumented filter pre_insert_term.

What you need is not a filter, but an action called before insert terms, i have not found WordPress have this kind of action.

for another way of thinking, you can use create_term or created_term action, although they are called after term created, if a user have no permission, we can delete the term they just created.

Leave a Comment