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' => $vid,
'parent' => $parent,
'name' => 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' => $term->tid, 'name' => $term->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?
hook_menu_alter
and implement more advanced access logic on your own callback