WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#10943 closed enhancement (fixed)

Need way to prohibit creation of new taxonomy terms

Reported by: sirzooro Owned by: filosofo
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.8.4
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

I have site where everyone can submit post. I have created categories, which are usually used by people. Unfortunately from time to time I get post (probably added by some automated software), which is added to newly created category, which name consists of digits only. Therefore I need some way to disable this, e.g. new filter called at beginning of wp_insert_term(), which can be used to deny operation.

Attachments (2)

taxonomy.php.diff (902 bytes) - added by sirzooro 6 years ago.
10943.patch (841 bytes) - added by prettyboymp 6 years ago.

Download all attachments as: .zip

Change History (7)

@sirzooro6 years ago

comment:1 @sirzooro6 years ago

  • Keywords has-patch added; needs-patch removed

Patch.

comment:2 @prettyboymp6 years ago

  • Cc mpretty@… added

I have a similar need, but this patch (attachment:taxonomy.php.diff) has some limitations. If wp_insert_term returns a WP_Error than the wp_set_object_terms will return directly after with an error, causing none of the terms to be mapped to the object. I think a better solution would be the ability to filter our the new terms before the loop even begins.

@prettyboymp6 years ago

comment:3 @sirzooro6 years ago

@prettyboymp: your solution does not address situation when someone adds new tag, etc. using other ways, e.g. page designed to manage tags. I think that your path may be a better solution for #9073.

comment:4 @ryan6 years ago

  • Milestone changed from 2.9 to 3.0

comment:5 @nacin6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [13430]) Add pre_insert_term hook to wp_insert_term(). fixes #10943 props sirzooro

Note: See TracTickets for help on using tickets.