Last active
December 20, 2015 07:58
-
-
Save shrop/6096689 to your computer and use it in GitHub Desktop.
Create a node object and save it (Drupal 7)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$node = new stdClass(); | |
$node->type = 'content_type'; | |
$node->title = 'Node Title'; | |
// Set the language. | |
$node->language = LANGUAGE_NONE; | |
// Custom field. | |
$node->field_custom[$node->$language][0]['value'] = 'Custom field data'; | |
// Prepare and save the node. | |
node_object_prepare($node); | |
$node = node_submit($node); | |
$node->revision = TRUE; | |
node_save($node); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment