To learn more about how events work, see the Craft documentation on events (opens new window).
Raised before a comment is saved. Event handlers can prevent the comment from getting saved by setting $event->performAction
to false.
Params: - comment – The CommentModel that is about to be saved.
craft()->on('comments.onBeforeSaveComment', function($event) {
$comment = $event->params['comment'];
$event->performAction = false;
});
Raised after a comment has been saved.
Params: - comment – The CommentModel that has been saved.
craft()->on('comments.onSaveComment', function($event) {
$comment = $event->params['comment'];
});
Raised before a comment is 'trashed'. Event handlers can prevent the comment from getting trashed by setting $event->performAction
to false.
Params: - comment – The CommentModel that is about to be trashed.
craft()->on('comments.onBeforeTrashComment', function($event) {
$comment = $event->params['comment'];
$event->performAction = false;
});
Raised after a comment has been 'trashed'.
Params: - comment – The CommentModel that has been trashed.
craft()->on('comments.onTrashComment', function($event) {
$comment = $event->params['comment'];
});
Raised before a comment is flagged. Event handlers can prevent the comment from getting flagged by setting $event->performAction
to false.
Params: - comment – The CommentModel that is about to be flagged.
craft()->on('comments_flag.onBeforeFlagComment', function($event) {
$comment = $event->params['comment'];
$event->performAction = false;
});
Raised after a comment has been flagged.
Params: - comment – The CommentModel that has been flagged.
craft()->on('comments_flag.onFlagComment', function($event) {
$comment = $event->
params['comment'];
});
Raised before a comment is voted on. Event handlers can prevent the comment from getting voted on by setting $event->performAction
to false.
Params: - comment – The CommentModel that is about to be voted on.
craft()->on('comments_vote.onBeforeVoteComment', function($event) {
$comment = $event->params['comment'];
$event->performAction = false;
});
Raised after a comment has been voted on.
Params: - comment – The CommentModel that has been voted on.
craft()->on('comments_vote.onVoteComment', function($event) {
$comment = $event->params['comment'];
});