如何在 drupal 中以编程方式删除论坛评论?
在我的网站中,我需要为用户提供删除选项,以删除他们自己在论坛中的评论。我想删除评论并更新评论节点统计信息。 Drupal 有没有删除评论的功能?
In my website I need to give a delete option for users to remove their own comment in a forum. I want to delete comments and update comment node statistics. Is there any Drupal functions available to delete comments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 Drupal 7 中,有 comment_delete_multiple() 调用评论删除涉及的钩子,通过 _comment_update_node_statistics()。它需要一组评论 ID。
在 Drupal 6 中,没有等效的函数,但您可以编写与 Drupal 7 函数等效的函数,考虑到:
db_delete()
或comment_load_multiple()
的任何等效项In Drupal 7 there is comment_delete_multiple() which invokes the hooks involved in the comments deletion, and updates the node statistics through _comment_update_node_statistics(). It requires an array of comment IDs.
In Drupal 6, there isn't an equivalent function, but you write the equivalent of the Drupal 7 function, considering that:
db_delete()
orcomment_load_multiple()
http://drupal.org/documentation/modules/trigger
Drupal 触发器。
http://drupal.org/documentation/modules/trigger
Drupal trigger.
类似...
这个解决方案适用于 Drupal 6,但您也可以从注释模块借用包含文件并劫持其他版本中的功能。
我不确定扩展核心论坛功能的 contrib 模块(如 高级论坛)是否提供了无需编写的选项自定义代码,但您可能想研究一下。
Something like...
This solution is for Drupal 6 but you can borrow include files from the comment module and hijack their functions in other versions too.
I'm not sure if contrib modules extending the core forum functionality (like Advanced Forum) provide an option without writing custom code, but you might want to look into it.
德鲁帕尔7
使用comment_delete()
Drupal 7
Use the comment_delete()