I am not sure how to do this; I want to manually submit a comment.
Asked
Active
Viewed 1,366 times
2 Answers
1
If you are using Drupal 6, you'll want to take a look at both comment_form_submit() and comment_save(). For Drupal 7, comment_save() is much more of a true API function, so if you are properly preparing your comment, that's all you should need.

jhedstrom
- 3,378
- 1
- 23
- 19
-
Hi thanks. i have tried in drupal 6. But I need some working examples – Navane Mar 25 '11 at 09:04
0
$user = user_load(array(uid => $a_uid));
$forum_comment_fields = array();
$forum_comment_fields['values']['author'] = $user->name;
$forum_comment_fields['values']['subject'] = "";
$forum_comment_fields['values']['comment'] = $comment;
$forum_comment_fields['values']['op'] = t('Save');
$forum_comment_fields['values']['nid'] = $nid;
$forum_comment_fields['values']['date'] = $created;
comment_form_submit("comment_form", $forum_comment_fields);
I think the date is incorrect...

James
- 477
- 4
- 6