3

Possible Duplicate:
Can I turn off write-in tags/taxonomies?

I am trying to disable creation of new tags for posts. If a tag is in exisiting list of tags, it will be added with post otherwise deleted. The code i am using doesn't seem to work. Here is the code

add_filter( 'pre_post_tags_input', 'no_tags_input_create' );




add_action( 'publish_post', 'no_tags_input_create' ); 

add_action( 'publish_updated', 'no_tags_input_create' );

add_action( 'save_post', 'no_tags_input_create' );


function no_tags_input_create($post_ID) {
$taxonomy_ar = wp_get_post_tags( $post_ID ); 


 if (count($taxonomy_ar) > 0){   
 foreach ($taxonomy_ar as $taxonomy_term) {    

 $term_ids= $taxonomy_term->term_id;
 $tags_name[]= $taxonomy_term->name;
}

}
    $output = array();

    foreach( $tags_name as $tag )
        if( !term_exists( $tag, 'post_tag') ){
             wp_delete_term($term_ids,'post_tag'); 
        wp_set_post_tags( $post_ID, '', false );
            }

}

Can anyone point out where i am wrong?

2
  • this is already solved on wp.se
    – Amit Kosti
    Aug 10, 2012 at 16:39
  • I am not sure if your requirements are or aren't identical to question suggested as duplicate above. Please clarify if they aren't then in what way.
    – Rarst
    Aug 10, 2012 at 17:07

0

Browse other questions tagged or ask your own question.