Is there any way to validate taxonomy terms? Is there any way to validate a taxonomy term before it will be saved? I'm using Simple Hierarchical Select with its "add new item" functionality. I would like to enable this option for registered users. They are not completely trusted though. What I would like to do is to create some limit on number of terms that can be added, for example per day. This is a ajax callback of SHS that creates new terms:

function shs_json_term_add($vid, $parent, $term_name) {
  if (!user_access('edit terms in ' . $vid)) {
    // Sorry, but this user may not add a term to this vocabulary.
    return FALSE;
  }

  $term = (object) array(
    'vid' =&gt; $vid,
    'parent' =&gt; $parent,
    'name' =&gt; check_plain(filter_xss($term_name)),
  );
  // Save term.
  $status = taxonomy_term_save($term);

  // Return term object or FALSE (in case of errors).
  return ($status == SAVED_NEW) ? array('tid' =&gt; $term-&gt;tid, 'name' =&gt; $term-&gt;name) : FALSE;
}


As you can see, it basically checks permissions and saves term by using taxonomy_term_save($term); . Would there be a way for validating this term without patching SHS module?
there are these lines in shs.module:

$callbacks = array(
    'shs_json_term_get_children' =&gt; array(
      'callback' =&gt; 'shs_json_term_get_children',
      'arguments' =&gt; array(
        'vid' =&gt; 'is_numeric',
        'parent' =&gt; 'is_array',
        'settings' =&gt; 'is_array',
      ),
    ),
    'shs_json_term_add' =&gt; array(
      'callback' =&gt; 'shs_json_term_add',
      'arguments' =&gt; array(
        'vid' =&gt; 'is_numeric',
        'parent' =&gt; 'is_numeric',
        'name' =&gt; 'is_string',
      ),
    ),
  );
// Let other modules add some more callbacks and alter the existing. (!)
drupal_alter('shs_json_callbacks', $callbacks);


I think we can do something like this:

function MY_MODULE_json_callbacks(&amp;$callbacks) {
  $callbacks['shs_json_term_add']['callback'] = 'CUSTOM_CALLBACK';
}

function CUSTOM_CALLBACK($vid, $parent, $term_name) {
  if(!NEW_CONDITIONS) {
    return FALSE;
  }

  return shs_json_term_add($vid, $parent, $term_name);
}