How to find out a node's comment status (open, closed) from node ID? Having a view of comment fields here that is embedded into another view via Views Field View module. The comment view has a contextual filter: the nid. Works quite nice.

Now I want to hide the view if comments ain't allowed (per node). Of course I have the node's ID as $argument. How can I check the comment status from that to specify the validate criteria?
The following code should do the trick:

$node = node_load($argument); // load the node object based on the nid
if($node-&gt;comment == COMMENT_NODE_CLOSED) {
  // comments are closed - hide the view
}


There are 3 constants that define the different comment states:


COMMENT_NODE_HIDDEN 
COMMENT_NODE_CLOSED
COMMENT_NODE_OPEN


For more information see the Node object reference.