function comment_unpublish_by_keyword_action

You are here

7 comment.module comment_unpublish_by_keyword_action($comment, $context)
6 comment.module comment_unpublish_by_keyword_action($comment, $context)

Action to unpublish a comment if it contains a certain string.


$comment: A comment object.

$context: An array providing more information about the context of the call to this action. Unused here, since this action currently only supports the insert and update ops of the comment hook, both of which provide a complete $comment object.

See also



Related topics

2 string references to 'comment_unpublish_by_keyword_action'
comment_action_info in modules/comment/comment.module
Implementation of hook_action_info().
hook_action_info in developer/hooks/core.php
Declare information about one or more Drupal actions.


modules/comment/comment.module, line 2121
Enables users to comment on published content.


function comment_unpublish_by_keyword_action($comment, $context) {
  foreach ($context['keywords'] as $keyword) {
    if (strpos($comment->comment, $keyword) !== FALSE || strpos($comment->subject, $keyword) !== FALSE) {
      db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $comment->cid);
      watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));