0

not sure why:

function MY_MODULE_comment_view_alter(&$build) {
    $build['#comment'] -> status = 0;    
}

does not work. It displays comment on the red background, however comment is still visible for all users with 'view comments' rights. What I would like to achieve is simply hide comment so it's not visible.

1

You achieve this by adding a comment_post_render callback function to the build that outputs nothing:

function MY_MODULE_comment_view_alter(&$build) {
  $build['#post_render'][] = 'MY_MODULE_comment_post_render';
}

function MY_MODULE_comment_post_render() {
  // Nothing here.
}
| improve this answer | |
0

I think you need this -

function MYMODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'node_view') {
    unset($implementations['comment']);
  }
}

Taken from the answer of a question here - Is there a way to stop comment_node_view from firing?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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