I try to add some fields to content type through this hook as it done in node_example module in Drupal 7 examples but it's not even invoked. What can be wrong?

function education_node_type_insert($content_type){
            $fields = _anketa_installed_fields();
            foreach($fields as $field){

            $instances = _anketa_installed_instances();
            foreach($instances as $instance){
                $instance['entity_type'] = 'node';
                $instance['bundle'] = 'anketa';
  • Are you sure your custom module is enabled? Did you clear cache after you added the implementation of hook_node_type_insert? – Pontus Nilsson Jul 30 '13 at 19:57
  • Yes, I even tried to disable and enable it back several times. Same thing with clearing cache – Dmitrii Mikhailov Jul 30 '13 at 20:42
  • Out of curiosity what is it you are trying to accomplish? – Pontus Nilsson Jul 31 '13 at 9:22
  • I'm just trying to create content type and add fields to it. In node_example example from drupal.org it works but in my case - doesn't. Just can't figure out why. – Dmitrii Mikhailov Jul 31 '13 at 14:56
  • Why not use the Features module to export your field definition? – Pontus Nilsson Aug 1 '13 at 15:05

This hook will only get called when node_type_save() is called - ie. when a new node type is saved to the database.

  • So the type should be saved in hook_install anyway? – Dmitrii Mikhailov Jul 31 '13 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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