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

Haluk Karamete halukkaramete at gmail.com
Thu Mar 21 04:14:03 UTC 2013


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.


More information about the wp-hackers mailing list