| Versions | |
|---|---|
| 7 | hook_taxonomy_term_insert($term) |
Act on taxonomy terms when inserted.
Modules implementing this hook can act on the term object when saved to the database.
$term A taxonomy term object.
drupal/
<?php
function hook_taxonomy_term_insert($term) {
if (!empty($term->synonyms)) {
foreach (explode("\n", str_replace("\r", '', $term->synonyms)) as $synonym) {
if ($synonym) {
db_insert('taxonomy_term_synonym')
->fields(array(
'tid' => $term->tid,
'name' => rtrim($synonym),
))
->execute();
}
}
}
}
?>