You can achieve this by following steps given below:
- Create a flag on nodes for administrator only
- Add new rule using Rules module
- Set React on in Event "A node has been flagged, under
- Add action "Set a data value"
- Select Data "flagged-node:comment"
- 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;