[wp-hackers] monitoring the new tag creation by non-admins

Nathaniel Taintor goldenapplesdesign at gmail.com
Thu Mar 21 18:06:43 UTC 2013

Yeah, for one, I'm not sure why you would be hooking in to the
"wp_insert_post_data" and not something closer to what you're actually
to modify, like "pre_insert_term".

Modifying the name of the term also seems like a clumsy way of handling
It would seem, for the purposes you're describing, that an action which
runs on
"created_term" and either emails you or adds the new term to an option
which you can
then check from an admin screen, would be all that you would need to do.
the name of the term for anything other than giving users information seems
like in-band signalling that adds more confusion than it does value.

Nathaniel Taintor, Designer/Developer
*Golden Apples Design*

@GoldenApples | 717.434.3226
goldenapplesdesign at gmail.com

On Wed, Mar 20, 2013 at 9:14 PM, Haluk Karamete <halukkaramete at gmail.com>wrote:

> I'm trying to monitor the creation of the new tags when a non-admin or
> non-editor submits a new post.
> In another words, if a contributor or author submits a new post, I'd like
> to mark the new tags somehow so that I can do some maintenance work.
> For that I decided to use the prefix "newtag-" in front of those new tags.
> So I can go the dashboard tags interface and search for "newtag-", and do
> the maintenance.
> Here is a scenario... assume that "apple" is an old tag, and joe the
> contributor comes along and submits a new post with the tags "apple" and
> "mango" attached to it.
> I want that post to go as "apple" and "newtag-mango" automatically.
> now... for this goal at hand, I set out with
> add_filter('wp_insert_post_data', 'my_post_data_validator', '99');
> function my_post_data_validator($data) {
> }
> In the function, I programmatically change the incoming $post_tags from
> "apple,mango" to "apple,newtag-mango"
> and then I run
> $set_post_terms_result= wp_set_post_terms( $_POST['post_ID'],
> $modified_tags, "post_tag", FALSE ); // where $modified_tags is equal to
> "apple,newtag-mango"
> but after this plug in runs, I do get the "newtag-mango"
> created automatically on the fly. But unfortunately, WP goes ahead and uses
> its own wp_set_post_terms somewhere down the road with the 3rd arg being
> set to FALSE overwriting my own running of the wp_set_post_terms. It
> obviously uses the original $_POST array and as a result, joe's post ends
> up with "apple", & "mango".
> What do I need to do so that WP completely forgets about the
> wp_set_post_terms for the post_tags?
> Another solution could be to tap into the "wp_insert_term" and change the
> post tags thru a filter.  Maybe there is a filter to tell wp_insert_term
> hey don;t use apple and mango, but go ahead with apple newtag-mango. Then
> that would solve my problems.
> but firstly, I cannot figure it out, and secondly, approaching to this
> problem from these very angles may not be the best way to tackle this
> issue.
> Thus your help is greatly appreciated.
> Thx.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list