I have created a new node type using a custom module on Drupal 7. However when I check the content type under the structure menu item it isn't listed. Looking in the node_type table, I see that it is listed as disabled. My question is how do I get the content type to be enabled?

Here is my content type creation function located in mymodule.install file:

// define the node type
  $type = array(
    'type' => $machine_name,
    'name' => $t($parameters['name']),
    'base' => 'room_reservations',
    'module' => 'room_reservations',
    'description' => $t($parameters['description']),
    'has_title' => TRUE,
    'title_label' => $t($parameters['title_label']),
    'custom' => FALSE,
    'locked' => TRUE,
    'disabled' => FALSE,

// set other node defaults not declared above
  $content_type = node_type_set_defaults($type);

// add the body field
  node_add_body_field($content_type, $t($parameters['body_label']));

// save the content type

I believe this is correct but it obviously doesn't work. Any ideas

2 Answers 2


Drupal base install uses this configuration to create the basic page content type. Try to modify the custom value just like the example underneath:

$type = array(
    'type' => 'page',
    'name' => st('Basic page'),
    'base' => 'node_content',
    'description' => st("Use <em>basic pages</em> for your static content, such as an 'About us' page."),
    'custom' => true,
    'locked' => true,
    'modified' => true,
    'disabled' => false,


I've just checked the code of some Drupal core modules how they manage the creation of content types within code.

The Blog module defines the content type within the HOOK_node_info (just like you did). This to notify Drupal about the new type. The HOOK_install only add fields to the content type. The module also implement the HOOK_form for the content creation form and HOOK_view for the rendering.

// blog.install
function blog_install() {
  // Ensure the blog node type is available.
  $types = node_type_get_types();

// blog.module
function blog_node_info() {
  return array(
    'blog' => array(
      'name' => t('Blog entry'),
      'base' => 'blog',
      'description' => t('Use for multi-user blogs. Every user gets a personal blog.'),


  • The custom value indicates whether the content type was create by a module or by a user. In my case, setting it to false is the correct thing to do.
    – user5013
    Commented Oct 9, 2013 at 22:33
  • If you are still interested, I've updated my answer with the correct implementation for custom content types in code. Commented Oct 10, 2013 at 16:38

A possible answer to my own question. I believe that along with using hook_install() you must also use hook_node_info() as well. I was under the impression from reading the documentation that when adding fields to your node type, all you needed to do was use hook_install() as shown in the original question. That didn't work for me. It did work when I included hook_node_info() and that seemed to make the node types enabled. Am I correct that you have to use both these hooks in order to get custom node types to display?

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.