I'm creating a Drupal installation profile and transfering taxonomy vocabularies through features, like this:

; Features
dependencies[] = my_profile_taxonomy_vocabularies

These vocabularies are created correctly, but I also should automatically create terms. If I put my function which creates terms into my_profile_install(), it's not working. At this moment, vocabularies are not available. Also I've tried to use direct SQL query and vocabularies are not created at this moment.

Where can I put my code for terms creation, when vocabularies are already created and available?

1 Answer 1


You need to create a install task in .profile, install tasks are run after modules are enabled.

Here's an example you can use as a starting point:


 * Implements hook_install_tasks().
function PROFILE_install_tasks() {
  $tasks = array(
    'create_taxonomy_terms' => array(
      'display_name' => st('Create taxonomy terms'),
      'type' => 'normal', // the default
  return $tasks;

 * Install task: Create taxonomy terms.
function PROFILE_create_taxonomy_terms() {
  // your stuff.

The install task is declared as normal, that means the related function will be executed. If you're going to create a lot of terms, better write a batch. See the api docs for reference:


  • Thank you! It's works for me! And yes I need batch for my functionallity.
    – Eugene
    Aug 14, 2012 at 5:06

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.