Is it possible to automatically add a new taxonomy term (related to certain vocabulary) from a field in a custom content type; so when submitting a new content entry (related to that custom content type) I add a new taxonomy term related to that entry to create a richer tagging functionality by time for future entries?

  • Add a new taxonomy to what ?
    – tostinni
    Jun 10, 2011 at 18:52
  • The question is ambiguous. Can you please be more specific?
    – Adam S
    Jun 10, 2011 at 18:52
  • @tostinni: to a taxonomy vocabulary that already exists.
    – wassimans
    Jun 10, 2011 at 18:55
  • Could you give an example? Jun 12, 2011 at 10:43

1 Answer 1


Check out taxonomy_save_term(). Here's an example from the comments:

$term = array(
'vid' => 5, // Voacabulary ID
'name' => 'Drupal', // Term Name
'synonyms' => 'Druplet', // (Optional) Synonym of this term
'parent' => 11, // (Optional) Term ID of a parent term 
'relations' => array(15), // (Optional) Related Term IDs


You could use this inside hook_nodeapi() on the operations insert or presave (and update). See the comments at the first link for more info.

EDIT: For drupal 7 you have to check out the node api instead of of hook_nodeapi().


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.