Opened 16 years ago
Closed 15 years ago
#9073 closed enhancement (wontfix)
wp_insert_post_data should allow to modify categories and tags too
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.7 |
Component: | General | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
It will be good to pass categories and tags to wp_insert_post_data filter. I wrote plugin which checks how many tags and categories are used, and I had to access POST data directly to do this. With this change, my plugin could access this data in easier way. This change will also open way to write new kinds of plugins, which can change categories and tags just before post is saved.
Attachments (1)
Change History (15)
#2
@
16 years ago
Thanks. This is exactly what I was looking for.
I leave this ticket open, so you can either implement this enhancement in the future, or you can close it.
#3
@
16 years ago
- Milestone 2.8 deleted
- Resolution set to wontfix
- Status changed from new to closed
Since you can accomplish what you want with existing filters, let's close it.
#4
follow-up:
↓ 6
@
16 years ago
- Keywords needs-patch added
- Milestone set to 2.9
- Resolution wontfix deleted
- Status changed from closed to reopened
I would like to extend my plugin (WyPiekacz) again. This time I want to add options to automatically enforce rules when post is published - namely remove extra links, tags and categories. I can do this for links using this filter, but cannot do this for tags and categories. Therefore I am reopening this ticket.
#5
@
16 years ago
- Summary changed from wp_insert_post_data should have access to categories and tags too to wp_insert_post_data should allow to modify categories and tags too
#6
in reply to:
↑ 4
@
16 years ago
Replying to sirzooro:
I would like to extend my plugin (WyPiekacz) again. This time I want to add options to automatically enforce rules when post is published - namely remove extra links, tags and categories. I can do this for links using this filter, but cannot do this for tags and categories. Therefore I am reopening this ticket.
Could you please provide a specific example of something that you are unable to do with the current filters?
#7
@
16 years ago
I want to check how many tags post have, when post is saved. If there will be too many (e.g. 15, when limit is set to 10), I would like to extra ones (in this case remove last 5). I cannot do this with wp_insert_post_data filter - it allows to count tags, but does not allow to modify them. The same applies for categories and custom taxonomies too.
I know that it is possible to modify $_POST array directly (e.g. in init hook, or even earlier), but this approach is a bit tricky. So I would like to see easier method.
#9
@
15 years ago
- Keywords has-patch needs-testing added; needs-patch removed
- Milestone changed from Future Release to 2.9
Attached patch adds three filters to wp_insert_post()
: wp_insert_post_category
, wp_insert_post_tags
and wp_insert_post_tax
. They can be used by plugins to modify categories, tags (passed in pre-WP2.8 way) and taxonomies.
#11
@
15 years ago
Future Release sounds like "maybe sometimes, maybe never". If now it is too late to include it in 2.9, move it to 3.0 :)
#12
@
15 years ago
It used to be that tickets with patches went to the next version, and "Future" was for those without patches.
I think that's a good policy, because it somewhat helps to limit ticket rot. If you're moving a ticket with patch to "Future", it's probably better just to close it as "wontfix" or the like.
If the post categories are set, they are passed to wp_insert_post_data. Do something like this to access them:
However, that will allow you to change only core post data, not the categories or tags themselves. To do that, use the "wp_insert_post" filter.