Plugin to restrict non-admin user to existing tags

Is there a plugin that would restrict non-admin users to only existing tags? I could have used categories for this, but it will be difficult to display with a large population (~1000) of tags.

Related posts

Leave a Reply

4 comments

  1. If you do not already have your tags created, you can use the “Bulk Add Tags” plugin – http://wordpress.org/extend/plugins/bulk-add-tags/

    Then to restrict all users except admins from adding new tags via the “New Post” screen, add this code to your theme’s functions.php file:

    //Hide Post Page Options from all except Administrator
    if (!current_user_can('administrator')){
    function hide_post_page_options() {
    global $post;
    $hide_post_options = "<style type="text/css"> .jaxtag { display: none; }</style>";
    print($hide_post_options);
    }
    add_action( 'admin_head', 'hide_post_page_options'  );
    }
    

    This will simply hide the box for entering new tags from all users except administrators.

    I actually use this method to hide many areas of the “New Post” page. Simply find and add the element’s div class or id before { display: none; } and separated by commas. If you’re unfamiliar, you can use the Firebug plugin with Firefox, or simply right-click and select “Inspect Element” in Chrome.

    I prefer this method over many plugins because it does not remove functionality completely from WordPress, the functionality is simply hidden from users who do not need it.

  2. None of these solutions did exactly what I needed to allow non-admin users to use existing tags on a post, but not create new tags. So I created the following solution, which works great – although it does not provide any feedback to the user that their tags weren’t added (it really just undoes the tag creation immediately):

    add_action('create_term','undo_create_term',10, 3);
    
    function undo_create_term ($term_id, $tt_id, $taxonomy) {
        if ( !current_user_can( 'administrator' ) )  {
            if($taxonomy == 'post_tag') {
            wp_delete_term($term_id,$taxonomy);
            }
        }
    }
    
  3. Your question has really intrigued me. I can see a huge use for this situation, so I will do whatever I can to help you find the answer.

    Here is another solution, not exactly what you mentioned in your comment on the other answer, but it does make it a little easier for users to find the tags they want, as the tags are listed alphabetically.

    Manage Tags Capability plugin – http://wordpress.org/extend/plugins/manage-tags-capability/

    Also, should note: This method allows users to select from ALL available tags. I just realized, the other method only allows users to select from the “most used” tags.

    WordPress already does an auto-predict when typing tags, so essentially, we need to find a way to allow users to type the tag they want, but not add a new one if they cannot find it.

  4. This is how I solve same problem (in functions.php of your theme):

    /* Removing Tags for users */
    if (is_admin()) :
    function my_remove_meta_boxes() {
     if(!current_user_can('publish_posts')) { 
       remove_meta_box('tagsdiv-post_tag', 'post', 'normal');
     }
    }
    add_action( 'admin_menu', 'my_remove_meta_boxes' );
    endif;
    

    First we check if it’s admin area, then we check if user can publish posts (usually it’s admins and editors), than we do our magic with remove_meta_box.