#3458 closed enhancement (fixed)
Filter cat_ID when a new category is created
Reported by: | donncha | Owned by: | markjaquith |
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | normal | Version: | 2.1 |
Component: | Administration | Keywords: | |
Focuses: | Cc: |
Description
This patch adds a filter to wp_insert_category() to modify the cat_ID just before returning it.
Attachments (1)
Change History (9)
#2
@
17 years ago
- Version set to 2.1
Yeah, I see no reason why one would need to change the ID either. It's all used internally and you can encounter major problems if you change them.
#3
@
17 years ago
This filter is used in WPMU to modify the cat_ID so it matches a cat_ID in a global categories table. On a regular wordpress install it could be used to sync the cat_ID in the categories table with a tag ID elsewhere.
#5
@
17 years ago
Actually, slight issue. Look at the lines above it. Don't you think it would be better if the cat_ID filter were called on line 135, before all those other actions are called on the OLD id?
#6
@
17 years ago
I thought about that and reasoned that those actions should happen on the unmodified cat_ID because that's what's in the db, but that makes no sense. It's probably better to have the new filter work it's magic before the actions so feel free to bump it up higher in the code!
#8
@
17 years ago
I gave it a second param... the $update flag, which will be TRUE or FALSE (TRUE representing a pre-existing category). If $update is false, you don't need to bother checking for post2cat entries to update.
I gave some inline notes as well, as this is a pretty powerful hook that could really mess things up if not fully understood.
Is the assumption that if someone wanted to change the cat_ID, they'd make the appropriate UPDATE query? Why should the cat_ID matter (such that you'd want to change it)?