Make WordPress Core

Opened 2 months ago

Last modified 8 weeks ago

#60532 new enhancement

Add a `pre_set_object_terms` action

Reported by: davidbaumwald's profile davidbaumwald Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.5
Component: Taxonomy Keywords: good-first-bug has-patch
Focuses: Cc:

Description

Working with some custom terms & taxonomies, and it looks like there's no way to hook in to wp_set_object_terms _before_ the terms are updated.

In the end, the $old_tt_ids is passed to the set_object_terms action(added in r12261). But, these are the term_taxonomy_ids and a a bit harder to work with than the plain terms. Also, these are provided _after_ the terms are updated. So, there's no way to short-circuit the updating.

However, I think it would be useful to have a pre_ action that can work on the current terms before commiting the changes.

Attachments (1)

60532.patch (866 bytes) - added by sagarsavani7979 8 weeks ago.
This commit adds a new action hook, 'pre_set_object_terms', to the wp_set_object_terms function. This hook fires before an object's terms are set, allowing developers to perform operations or modifications on the terms array before the changes are committed.

Download all attachments as: .zip

Change History (3)

#1 @davidbaumwald
2 months ago

  • Keywords good-first-bug needs-patch added

@sagarsavani7979
8 weeks ago

This commit adds a new action hook, 'pre_set_object_terms', to the wp_set_object_terms function. This hook fires before an object's terms are set, allowing developers to perform operations or modifications on the terms array before the changes are committed.

#2 @sagarsavani7979
8 weeks ago

  • Keywords has-patch added; needs-patch removed
Note: See TracTickets for help on using tickets.