1 comment.api.php hook_comment_presave($comment)

Act on a comment being inserted or updated.

This hook is invoked from comment_save() before the comment is saved to the database.

Parameters

$comment: The comment object.

Related topics

File

core/modules/comment/comment.api.php, line 21
Hooks provided by the Comment module.

Code

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