I've been tasked to set up a Q&A styled project where we invite an industry leader, subject matter expert (SME) to answer questions for hopeful students in the same field. The individual requesting this project is a fan of reddit's Ask-Me-Anything styled interviews. So, yes, that is a big driver of this project.

We'll have a period of a week where the students can ask questions and two weeks where the SME can respond to those questions. In the fourth week, both can further respond with follow up questions or expanded responses. After that, the conversation will be available as read-only archive with nothing new added. I'm thinking nested comments would be sufficient.

Can I tell Drupal to open and close comments on certain dates, or even use a date field of when comments should be closed?
I'm okay with either using a contributed module (I haven't found one), Rules (I've not used very much), or custom code (My default, but there are people much smarter than me who have probably already done this better).

2 Answers 2


That should be as simple as:

function MYMODULE_node_view($node, $view_mode, $langcode) {
  if (/* Your logic to determine that comments are closed here */) {
    $node->content['comments']['#access'] = FALSE;

(it'll probably need to be tweaked for your exact requirements, have a look at what else lives in $node->content['comments'] if you want to hide the form/existing comments separately).


I'm assuming you have a content type for this, say "Question", for which you want to enable / disable comments. Refer to the steps below about how to do so.

Step 1 - Create a list

Start with creating a VBO list of all relevant questions, whereas in your view you use any relevant filters, etc.

Step 2 - Create a rule to enable comments

Use this VBO list to do something that is similar to what is shown in the video about Using VBO to load list of objects into Rules, starting from about 5:30, up to 11:30. Here is a summary of what is shown in this video (quote from the linked page):

  • You need a view that lists the entities you want to work on in Rules. Note that you don't need a display of the view – and it might even be better not to have one if you don't want the view to be displayed somewhere.
  • However, you need one bulk operations field. The type of bulk operations field determines what entity type will be sent to Rules. Note that you don't need any actions enabled for the field – it is enough that it is present.
  • You need a rule that, as an action, loads entities from a VBO. (This is available under the "Views bulk operations" group.) All view displayes with at least one VBO field will be selectable.
  • The action provides a list of entities, that can be used just like other lists in Rules. Combine with loops, actions and Rules Scheduler to make awesomeness happen.

In your case you want to start from that VBO list of questions for which comments are to be enabled. And for each node in the list you want the rules action to be something like "enable comments", instead of "remove sticky" (as in the video).

Should you need any other rules "conditions", you can add them to the rules component you created.

Step 3 - Trigger the rule to enable comments

The Rules component that you create as described above, should then become the action to be performed by a rule that is triggered automatically, via the Rules Scheduler. This is what is shown in the video (mentioned in Step 2), starting from 11:30. In the video the Rules component is triggered daily, though you want it to be triggered "on certain dates". As an alternative for using the scheduler (eg if these dates may vary), you can also trigger the rule by just executing the rule from the Rules UI (whenever the time is right).

Step 4 - Create and trigger the rule to disable comments

The above is to "enable comments", but you can use a similar approach to "disable comments" also of course (via a 2nd rule).

  • This is what is shown in the video, starting from 11:30 what video? I think you forgot to link to the video.
    – No Sssweat
    Commented Sep 18, 2015 at 0:08
  • @NoSssweat : I clarified step 3 a bit (= same video as in step 2), hope that helps ... Commented Sep 18, 2015 at 5:46

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.