[development] create comment via drupal_form_submit() - possible?

David Cohen drupal at dave-cohen.com
Sat Jan 29 02:06:00 UTC 2011

In D6, creating content via drupal_execute() was difficult.  In D7 using
drupal_form_submit() seems even more so.  Thanks to fields, I can't tell
how to pass in the body of  a comment or node.

Does anyone have an example snippet that creates a comment via
drupal_form_submit().  Or any other programmatic way?

I'm building my comment during a cron job.  I want the automatically
generated comment to be attributed to the Anonymous user.  But,
anonymous does not have permission to "post comments", and
comment_form_submit() refuses to save the new comment unless
user_access('post comments').  I consider that a bug - that check is
made before showing the form and should not be made during submit.  What
do you think?  http://drupal.org/node/1044212


More information about the development mailing list