4.7.x node.php hook_node_info()
5.x node.php hook_node_info()
6.x node.php hook_node_info()
7.x node.api.php hook_node_info()

Define module-provided node types.

This is a hook used by node modules. This hook is required for modules to define one or more node types. It is called to determine the names and the attributes of a module's node types.

Only module-provided node types should be defined through this hook. User- provided (or 'custom') node types should be defined only in the 'node_type' database table, and should be maintained by using the node_type_save() and node_type_delete() functions.

Return value

An array of information on the module's node types. The array contains a sub-array for each node type, with the machine-readable type name as the key. Each sub-array has up to 10 attributes. Possible attributes:

  • "name": the human-readable name of the node type. Required.
  • "module": a string telling Drupal how a module's functions map to hooks (i.e. if module is defined as example_foo, then example_foo_insert will be called when inserting a node of that type). This string is usually the name of the module in question, but not always. Required.
  • "description": a brief description of the node type. Required.
  • "help": text that will be displayed at the top of the submission form for this content type. Optional (defaults to '').
  • "has_title": boolean indicating whether or not this node type has a title field. Optional (defaults to TRUE).
  • "title_label": the label for the title field of this content type. Optional (defaults to 'Title').
  • "has_body": boolean indicating whether or not this node type has a body field. Optional (defaults to TRUE).
  • "body_label": the label for the body field of this content type. Optional (defaults to 'Body').
  • "min_word_count": the minimum number of words for the body field to be considered valid for this content type. Optional (defaults to 0).
  • "locked": boolean indicating whether the machine-readable name of this content type can (FALSE) or cannot (TRUE) be edited by a site administrator. Optional (defaults to TRUE).

The machine-readable name of a node type should contain only letters, numbers, and underscores. Underscores will be converted into hyphens for the purpose of constructing URLs.

All attributes of a node type that are defined through this hook (except for 'locked') can be edited by a site administrator. This includes the machine-readable name of a node type, if 'locked' is set to FALSE.

For a detailed usage example, see node_example.module.

Related topics

3 functions implement hook_node_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

blog_node_info in modules/blog/blog.module
Implementation of hook_node_info().
forum_node_info in modules/forum/forum.module
Implementation of hook_node_info().
poll_node_info in modules/poll/poll.module
Implementation of hook_node_info().
2 invocations of hook_node_info()
node_type_reset in modules/node/content_types.inc
Resets all of the relevant fields of a module-defined node type to their default values.
_node_types_build in modules/node/node.module
Builds and returns the list of available node types.


developer/hooks/node.php, line 68
These hooks are defined by node modules, modules that define a new kind of node.


function hook_node_info() {
  return array(
    'book' => array(
      'name' => t('book page'),
      'module' => 'book',
      'description' => t("A book is a collaborative writing effort: users can collaborate writing the pages of the book, positioning the pages in the right order, and reviewing or modifying pages previously written. So when you have some information to share or when you read a page of the book and you didn't like it, or if you think a certain page could have been written better, you can do something about it."),


michaelfavia’s picture

If you implement this hook you MUST also implement a hook_form() if you want that node type to appear in the content type list.

wweibel’s picture

and in addition ...

if you want the node content form to display the labels you specify read here: http://api.drupal.org/api/drupal/developer--hooks--node.php/function/hoo...

enricostn’s picture


could anyone explain me how to use hook_node_info() and hook_form() please?

I have created a new feature and in my doc_feature.features.inc I have:

 * Implementation of hook_node_info().
function doc_feature_node_info() {
  $items = array(
    'doc' => array(
      'name' => t('Doc'),
      'module' => 'features',
      'description' => '',
      'has_title' => '1',
      'title_label' => t('Document title'),
      'has_body' => '1',
      'body_label' => t('Body'),
      'min_word_count' => '0',
      'help' => '',
  return $items;

When I activate my custom feature the "Doc" type node is created BUT the title label is "Title" and not what I have in my .inc file "Document title".

I've read that I have to use the hook_form(), but where/how? in the .module file?

Thank you in advance,


ruudi33’s picture

Hi ocirne,

here's how to use hook_form in order to show title and body labels.

function doc_feature_form($node, $form_state)
return node_content_form($node, $form_state);