How To Remove a "Reply" Link In Drupal 7 Comments

30 Aug · by Tim Kamanin · 1 min read

In your _template.php_ file add the following code:

function themename_preprocess_comment(&$variables) {
  unset($variables['content']['links']['comment']['#links']['comment-reply']);
}

Don't forget to change _themename_ to your theme 's name. Now, everything should be working.

Comments

Required for comment verification



Reign85

However this don't avoid user with drupal knowledge to post replies by typing the direct URL, we prolly fix this by altering hook_menu_alter

Reply · 5 years, 3 months ago
apparatus

Thanks, Tim! That's what I was looking for!

Reply · 5 years, 3 months ago
Mike Skull

Ive used this in the past to help manage it using the admin area on a content type basis: (so as to avoid a push to live to change it for a new content type added for instance) http://drupal.org/project/flatcomments Thought it might help

Reply · 5 years, 3 months ago
Vasi

Yes, that's pretty much the only solution to this issue... Maybe a more flexible solution would be to use a separate permission for this.

Reply · 5 years, 3 months ago
Alex

That'll work but the more elegant approach would be to use hide() instead of unset() so that it's still in the render array and just flagged so its not shown. http://api.drupal.org/api/drupal/includes!common.inc/function/hide/7

Reply · 5 years, 3 months ago