1

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.

2 Answers 2

2

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. } 
0
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?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.