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
The ID of the flag.
The ID of the comment that was flagged.
The ID of the user who flagged the comment. It’s null when a guest flagged it.
The ID of the session the flag was made from, which identifies a guest’s flags.
The IP address the flag was made from. It’s only stored when Craft’s storeUserIps setting is on.
Methods
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>