hook_comment_presave

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 hook_comment_presave($comment)

The comment passed validation and is about to be saved.

Modules may make changes to the comment before it is saved to the database.

Parameters

$comment The comment object.

Related topics

Code

modules/comment/comment.api.php, line 21

<?php
function hook_comment_presave($comment) {
  // Remove leading & trailing spaces from the comment subject.
  $comment->subject = trim($comment->subject);
}
?>