Skip to content

Instantly share code, notes, and snippets.

@alechko
Last active December 18, 2015 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alechko/5720062 to your computer and use it in GitHub Desktop.
Save alechko/5720062 to your computer and use it in GitHub Desktop.
Create node in drupal
<?php
// Create a node object, and add node properties.
$newNode = new stdClass();
$newNode->type = 'node_example';
$newNode->uid = 0;
$newNode->created = strtotime("now");
$newNode->changed = strtotime("now");
$newNode->status = 1;
$newNode->comment = 0;
$newNode->promote = 0;
$newNode->moderate = 0;
$newNode->sticky = 0;
$newNode->language = 'und';
$newNode->field_email['und'][0]['value'] = $form_state['values']['email'];
// Save the node.
node_save($newNode);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment