0
votes

I would like to make one form that allow to user to add post for my content-type. form will have all fields that I have created in content type. once user will submit the from then entry will automatically add in content-type.

2

2 Answers

1
votes

You can add creation the new node in the form submit function

function custom_page_submit($form, &$form_state) {
  global $user;

  //Create new object and fill the fields;
  $node = new stdClass();
  $node->title = "SOME TITLE";
  $node->type = "YOUR_NODE_TYPE";
  node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().
  $node->language = LANGUAGE_NONE; // Or e.g. 'en' if locale is enabled
  $node->uid = $user->uid; 
  $node->status = 1; //(1 or 0): published or not
  $node->promote = 0; //(1 or 0): promoted to front page
  $node->comment = 1; // 0 = comments disabled, 1 = read only, 2 = read/write

  $node = node_submit($node); // Prepare node for saving
  node_save($node);
  // Display success message
  drupal_set_message("Node was saved!");
  // And you can specify where user shoul be redirected
  $form_state['redirect']  = 'SOME WHERE'; // 'front' - if redirect to front page
}
0
votes

Use common node creating system and just force it to use front-end theme.