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

Ken Rickard agentrickard at gmail.com
Sat Jan 29 03:26:58 UTC 2011

IMO, any access check in a validate or submit is a bug because they break form_alter and programmatic submissions.  And I'm pretty sure I opened an issue to that effect. 

I just need to find that issue. But it's late and I'm ranting via phone. 

On Jan 28, 2011, at 9:06 PM, "David Cohen" <drupal at dave-cohen.com> wrote:

> 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
> -Dave

More information about the development mailing list