Reference

Flag

A flag is a report that a comment is inappropriate. Flagging is turned on with the allowFlagging setting, and guests can only flag comments when allowGuestFlagging is also on. In templates, you’ll usually work with a comment’s flags through its getFlags(), isFlagged() and hasFlagged() methods on the Comment rather than with Flag objects. Flag events and the flagComment GraphQL mutation give you a Flag.

Properties

id

The ID of the flag.

commentId

The ID of the comment that was flagged.

userId

The ID of the user who flagged the comment. It’s null when a guest flagged it.

sessionId

The ID of the session the flag was made from, which identifies a guest’s flags.

lastIp

The IP address the flag was made from. It’s only stored when Craft’s storeUserIps setting is on.

Methods

getComment()

Returns the Comment that was flagged.

Flagging a Comment

You can flag a comment using a POST request to an action controller, and the following template code. You must supply a commentId and siteId in your form.

<form role="form" method="post" accept-charset="UTF-8">
    <input type="hidden" name="action" value="comments/comments/flag">
    <input type="hidden" name="siteId" value="{{ comment.siteId }}">
    <input type="hidden" name="commentId" value="{{ comment.id }}">
    {{ csrfInput() }}

    <button type="submit">{{ 'Flag' | t('comments') }}</button>
</form>
Last updated: Nov 13, 2026, 3:16:05 PM