Custom comment access I need to prevent users from posting comments based on some conditions but I can't find any hooks I can implement.

For nodes we have hook_node_access() but apparently there is no hook_comment_access()

Any ideas on how I can implement this?

I have tried something like this but apparently it doesn't work:

function my_module_entity_info(&amp;$entity_info) {
  $entity_info["comment"]["access callback"] = "my_module_comment_access_callback";
}

function my_module_comment_access_callback($op, $comment){
  // some custom logic and return false...
  //...
  return comment_access($op, $comment);
}


My form is a custom form, displayed on multiple pages. I would like to prevent access to the comment entity and not to the form or page.
You can get code from Comment Permissions and Comment Access modules.

something like 

function comment_perm_form_alter(&amp;$form, $form_state, $form_id) {
  #comment_node_merci_reservation_form
  if ($form['#id'] == 'comment-form' and arg(0) == 'comment') {
    $types = variable_get('comment_perm_node_types', array());
    $form_id_types = array();
    if (is_array($types)) {
      foreach ($types as $type) {
        if ($form_id == 'comment_node_' . $type . '_form') {

          $nid = $form['nid']['#value'];
          if (! comment_perm_access($nid)) {
            // for comment reply pages, redirect back to the node
            if (arg(0) == 'comment' &amp;&amp; arg(1) == 'reply' &amp;&amp; is_numeric(arg(2))) {
              drupal_set_message(_comment_perm_access_denied_message($nid), 'error');
              drupal_goto('node/' . arg(2));
    }
  }

          if (arg(0) == 'comment' &amp;&amp; arg(2) == 'edit' &amp;&amp; is_numeric(arg(1))) {
            if (! comment_perm_edit_access($nid)) {
              drupal_set_message(_comment_perm_access_denied_message($nid), 'error');
              drupal_goto('node/' . $nid);
            }
          }
      }
  }
    }
  }

}


then you can add you own condition.

You can also use above module ,if it is fulfilling your requirement.