Looking at the same kind of functionality in the user.module function user_comment_view() I would expect your code to work.
If your function is really called hook_comment_view
then it won't work though. Either this is just a typo, or rename your function to MYMODULE_comment_view
where MYMODULE
is the name of your custom module.
Edit: After a little discussion with MPD it turns out, that this actually works:
$comment->content['field_extra']['#access'] = FALSE;
Respect to MPD for explanations and an inside for why that could work and especially for why the other solution doesn't work!
This is the phrase from MPD that lead to the solution:
If you read the source for comment_build_comment()
, $comment->content[] has already been built up by the time the view hook gets invoked. So, messing with the field directly has no effect at this point.
Which means, that the field output has already been built and stored in $comment->content
, which implies that this follows the same rules as in hook_node_view()
. So accessing $comment->content[FIELD_NAME]
should work.