Drupal 7 – Starting point for programmatically creating a node

If you need to create a node within your module then use the following code:


title = '{NODE TITLE}';
$node->type = '{NODE TYPE}';
node_object_prepare($node);
$node->language = LANGUAGE_NONE;
$node->uid = $user->uid;
$node->status = 1;
$node->promote = 0;
$node->comment = 0;
$node = node_submit($node);
node_save($node);

Leave a Reply