You are here

function rules_action_taxonomy_add_term in Rules 6

Action: Add a new term to vocabulary.

Related topics

File

rules/modules/taxonomy.rules.inc, line 172
Rules integration for the taxonomy module.

Code

function rules_action_taxonomy_add_term($taxonomy_vocab, $settings) {

  // Prepare the values to pass to taxonomy_save_term();
  $settings['term']['vid'] = $taxonomy_vocab->vid;
  $form_values = $settings['term'];
  taxonomy_save_term($form_values);

  // Get the newly created term.
  $term = taxonomy_get_term($form_values['tid']);
  return array(
    'taxonomy_term' => $term,
  );
}