Limit the number of levels (depth) of a taxonomy vocabulary I would like to limit the depth of a taxonomy vocabulary to a maximum number parent/child nestings. I would like my users to not be able to add at most 4 levels deep of taxonomy terms per tree. Is there a module for this or what code is needed to enforce this depth on the tree?
After a lot of Googling and trial and error I came up with the following means of limiting a vocab's depth. You can make it as specific as you like:

Limit the depth of Parents on the term edit page:

function MY_MODULE_form_taxonomy_form_term_alter(&amp;$form, &amp;$form_state) {
  if ($form['#bundle'] == 'MY_VOCAB') {
    // Limit parents to none or only top level items
    foreach ($form['relations']['parent']['#options'] as $tid =&gt; $option) {
      if (substr($option, 0, 1) == '-') {
        unset($form['relations']['parent']['#options'][ $tid ]);
      }
    }
  }
}


Limit the depth of Tabledrag on the taxonomy terms listing page:

I could not re-implement theme_taxonomy_overview_terms() as another module had already done this and it made no sense to do that.

function MY_MODULE_preprocess_page(&amp;$variables) {
  if (current_path() == 'admin/structure/taxonomy/MY_VOCAB') {
    // Prevent tabledrag from allowing more than two levels in this hierarchy
    $settings['tableDrag']['taxonomy']['term-depth'][0] = array(
      'target' =&gt; 'term-depth',
      'source' =&gt; 'term-depth',
      'relationship' =&gt; 'group',
      'action' =&gt; 'depth',
      'hidden' =&gt; false,
      'limit' =&gt; 1,
    );
    drupal_add_js($settings, 'setting');
  }
}