User message after posting

You can choose to show a message to the user after posting. Use the code below for example:


{# @var commentsWork \twentyfourhoursmedia\commentswork\services\CommentsWorkService #} {% set commentsWork = craft.commentsWork.service %}

{# check if the user has just posted a comment and provide feedback #} {% set justPosted = commentsWork.checkJustPosted() %} {% if justPosted %} {% if justPosted.error %}

The comment could not be posted.

{% else %} {% if justPosted.status == 'APPROVED' %}

Your comment has been published.

{% elseif justPosted.status == 'PENDING' %}

Your comment has been posted and is awaiting moderation.

{% else %} {# the status is either trashed or spam for some reason,, #}

Your comment has been posted but has not been not published..

{% endif %} {% endif %} {% endif %}

You can also use this to choose to not display the form again after a user has posted a comment. Beware however that you can only call `commentsWork.checkJustPosted()` just once, after that the message has been reset.


{% set justPosted = commentsWork.checkJustPosted() %} {% if justPosted %} // (show 'you just posted a message') {% else %} // (show the form) {% endif %}