Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

While selecting tags for the posts the user is able to create new tags on fly.

For example we have the tag 'animal' but the user misstpye it as 'aminal' - and Wordpress creates it.

In our blog the strict tag structure is essential. How can I disable this function?

Edit

Solution added.

share|improve this question

2 Answers 2

YOu can deactive the default tag feature and add via plugin an custom taxonomie, that only list your created tags, like category meta box. Its also possible to design this how the tag meta box.

share|improve this answer
    
thank you, but how? –  boj Jul 31 '12 at 10:47
    
It is easy to remove an box via remove_meta_box(). Also, I think, do you find here on WPSE the soltuin for create an taxonomy. I have read this for longer time. –  bueltge Jul 31 '12 at 10:56
    
thank you, I'll try taxonomymanager.wordpress.com –  boj Jul 31 '12 at 11:14
    
not a solution for my problem :( it is really so hard to prevent users to create new tags? –  boj Jul 31 '12 at 21:58

Solution

Adding a hook to the create_term action works. Two things to do:

  • Check the referer, and if it comes from 'post.php', die
  • but before stopping, delete the new (and unwanted) tag with wp_delete_term($term_id, "post_tag");

Source code as plugin

<?php
/*
Plugin Name: Tag Checker
*/

add_action('create_term', 'tag_checker_hook');

function tag_checker_hook($term_id) 
{
    $referer = $_SERVER['HTTP_REFERER'];

    if (strpos($referer, "/wp-admin/post.php") !== false)
    {
        // Delete it
        wp_delete_term($term_id, "post_tag");

        wp_die("You are not able to create new tags.");
    }
}

?>
share|improve this answer
    
Now you're blocking yourself from creating new tags.. –  amit Aug 1 '12 at 11:19
    
no, just from the 'Post' form - and that' the goal. –  boj Aug 1 '12 at 13:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.