programmtically submit a node


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. require 'includes/bootstrap.inc';
  4. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  5.  
  6. global $mypost, $form_post_key;
  7. $mypost['edit']['title'] = 'robo-post: '. format_date(time(), 'small');
  8. $mypost['edit']['type'] = 'story'; // not needed?
  9. $mypost['edit']['body'] = 'viva druplicon';
  10. $form_post_key = 'mypost';
  11. $output = drupal_get_form('story_node_form', array()); // that final array() should be optional
  12.  
  13. print theme('page', $output);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.