Not a developer? Go to MovableType.com

Documentation

CommentFilter

This callback is invoked just prior to the MT::Comment object being saved. The callback is invoked prior to any spam/junk filtering or scoring being performed on the comment. This callback is a way for plugins to intercept the form submission of any newly submitted comment and perform additional validation on the comment.

Input Parameters

  • $cb - a reference to the current MT::Callback object handling this event.
  • $app - An instance of the MT::App::Comments used to process this comment submission.
  • $comment - A reference to the MT::Comment object being processed.

Return Value

A boolean (true/false) value. If any comment filter callback returns false (zero), the corresponding comment will not be saved in the database.

Example Handler

sub handler {
    my ($cb, $app, $comment) = @_;
    if ($comment->text =~ /a bad word/gm) {
        MT::Log->log({message => "Not saving comment
            because it has a bad word in it."})
        return 0;
    }
    return 1;
}

Tip: developers should consider logging a message in the activity log as to why a comment is being rejected, as this callback is otherwise opaque.

Back

Leave a Comment