2

Moderation scenario:

  1. Registered user publishes an entry using a front-end form that sets the entry to disabled.
  2. Moderator receives email re new entry and changes status from disabled to enabled in the CP.
  3. User receives email informing them that the entry has been enabled.

I’ve got steps 2 & 3 working using both the Courier & Postmaster plugins independently. However, when the user edits their entry via another front-end-form, they also receive an email notification.

How can the user be notified only when the entry has been edited and the entry's status has been changed from disabled to enabled?

Courier blueprints:

Step 2: Triggers: entries.onSaveEntry and Conditions: {{ entry.sectionId == '3' and isNewEntry ? 'true' : 'false' }}

Step 3: Triggers: entries.onSaveEntry and Conditions: {{ entry.sectionId == '3' ? 'true' : 'false' }}

2

In your Courier Blueprint listen to entry.beforeSaveEntry events and use this code for the Trigger Condition:

{% set oldEntry = craft.entries({
    id: entry.id,
    status: null,
}).first() %}

{%- set wasDisabled = oldEntry.status == 'disabled' %}
{%- set isEnabled = entry.status == 'live' %}

{{- wasDisabled and isEnabled ? 'true' : 'false' }}
  • Thanks Christian! I got it working as follows: {% set oldEntry = craft.entries.id(entry.id).status(null).first() %} {%- set wasDisabled = oldEntry.status == 'disabled' %} {%- set isLive = entry.status == 'live' %} {{- entry.sectionId == '3' and wasDisabled and isLive ? 'true' : 'false' }} I had to change enabled to live. – Andrea DeMers Jan 4 '18 at 21:19
  • Glad to hear, Andrea. I updated the answer accordingly. – carlcs Jan 5 '18 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.