3

My site editors want a quick way to close comments on a particular node, i.e. they just want to click a button on an item, rather than having to click edit, then select the comment settings tab, then click the "closed" box. (This is for Advanced forum, but I guess it could apply anywhere).

I have a feeling this should be fairly easy to do but I can't work out how to do it. Any pointers you can give would be appreciated. (I am using the Flag module and thought flag actions would be a simple way to do this, but closing comments doesn't seem to be an available action).

1 Answer 1

3

You can achieve this by following steps given below:

  1. Create a flag on nodes for administrator only
  2. Add new rule using Rules module
  3. Set React on in Event "A node has been flagged, under
  4. Add action "Set a data value"
  5. Select Data "flagged-node:comment"
  6. Click Continue and set value as 0

Please check Rule given below(exported):

{ "rules_disable_comments" : {
    "LABEL" : "Disable comments",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_disable_comments" : [] },
    "DO" : [
      { "data_set" : { "data" : [ "flagged-node:comment" ], "value" : "0" } },
      { "drupal_message" : { "message" : "Comments closed" } }
    ]
  }
}

& Flag given below(exported):

$flags = array();
// Exported flag: "Disable comments".
$flags['disable_comments'] = array (
  'entity_type' => 'node',
  'title' => 'Disable comments',
  'global' => '0',
  'types' => 
  array (
    0 => 'article',
  ),
  'flag_short' => 'Disable comments',
  'flag_long' => '',
  'flag_message' => '',
  'unflag_short' => 'Enable comments',
  'unflag_long' => '',
  'unflag_message' => '',
  'unflag_denied_text' => 'Disabled comments',
  'link_type' => 'toggle',
  'weight' => 0,
  'show_in_links' => 
  array (
    'full' => 'full',
    'teaser' => 'teaser',
    'rss' => 0,
    'search_index' => 0,
    'search_result' => 0,
    'token' => 0,
  ),
  'show_as_field' => 0,
  'show_on_form' => 0,
  'access_author' => '',
  'show_contextual_link' => 0,
  'i18n' => 0,
  'api_version' => 3,
);
return $flags;
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.