
Removing "Login or register to post comments" link from comment view
Drupal provides a handful of settings to format the comment listing. One thing that we found very irrelevant in comment view is the link item "Login or register to post comments" especially when the comments are styled to display as flat items. Let's take the snapshot below from drupal.org issue queue.
[[{"type":"media","view_mode":"media_original","fid":"102","attributes":{"alt":"","class":"media-image","typeof":"foaf:Image"}}]]
It is obvious that login and register link in every comment is not needed. Fortunately Drupal 7 provides a hook to alter comment view output hook_comment_view_alter(&$build)
-
/**
-
* Implementation of hook_comment_view_alter().
-
*/
-
function kf_module_comment_view_alter(&$build) {
-
if (($build['#node']->type == 'blog') && isset($build['links']['comment']['#links']['comment_forbidden'])) {
-
unset($build['links']['comment']['#links']['comment_forbidden']);
-
}
-
}
This five lines of code shared above does the trick of removing unwanted stuff from comment view.
Comments
I liked this post man very…
I liked this post man very much.
thanks
thanks
good post
good post