Can someone help me with this?
I have created a view that gives me a table of certain fields. Now I would like to add a "bulk operation" that lets users add an automatic comment to that specific node.
I have tried to ad a rule (component) and this was the result.
I have activated PHP-filter mode and tried with a component with "Execute custom PHP code".
The code in the component
<?php $comment = new stdClass(); $comment->nid = $node->nid; // nid of a node you want to attach a comment to (er stond 1) $comment->cid = 0; // leave it as is $comment->pid = 0; // parent comment id, 0 if none $comment->uid = $user->uid; // user's id, who left the comment //$comment->mail = 'email@example.com'; // user's email //$comment->name = 'User name'; // If user is authenticated you can omit this field, it will be auto-populated, if the user is anonymous and you want to name him somehow, input his name here //$comment->thread = '01/'; // OPTIONAL. If you need comments to be threaded you can fill this value. Otherwise omit it. //$comment->hostname = '127.0.01' // OPTIONAL. You can log poster's ip here $comment->created = time(); // OPTIONAL. You can set any time you want here. Useful for backdated comments creation. $comment->is_anonymous = 0; // leave it as is //$comment->homepage = ''; // you can add homepage URL here $comment->status = COMMENT_PUBLISHED; // We auto-publish this comment $comment->language = LANGUAGE_NONE; // The same as for a node $comment->subject = 'Comment subject'; $comment->comment_body[$comment->language]['value'] = 'Afgehaald'; // Everything here is pretty much like with a node $comment->comment_body[$comment->language]['format'] = 'filtered_html'; //$comment->field_custom_field_name[LANGUAGE_NONE]['value'] = ‘Some value’; // OPTIONAL. If your comment has a custom field attached it can added as simple as this // preparing a comment for a save comment_submit($comment); // saving a comment comment_save($comment); ?>
But when I go to the view and execute the operation, he asks for an identifier. But I want him to directly add the comment.
Can someone help me with this? Or is there another way?