Skip to content
Snippets Groups Projects
Commit 14ce7b4d authored by Angie Byron's avatar Angie Byron
Browse files

#545956 by claudiu.cristea: Add a presave hook to comments.

parent 92d53649
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,19 @@
* @{
*/
/**
* The comment passed validation and is about to be saved.
*
* Modules may make changes to the comment before it is saved to the database.
*
* @param $comment
* The comment object.
*/
function hook_comment_presave($comment) {
// Remove leading & trailing spaces from the comment subject.
$comment->subject = trim($comment->subject);
}
/**
* The comment is being inserted.
*
......
......@@ -1237,6 +1237,9 @@ function comment_save($comment) {
field_attach_presave('comment', $comment);
// Allow modules to alter the comment before saving.
module_invoke_all('comment_presave', $comment);
if ($comment->cid) {
// Update the comment in the database.
db_update('comment')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment