Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚩 Add support for more trigger events #2

Open
lindseydiloreto opened this issue Aug 24, 2021 · 15 comments
Open

🚩 Add support for more trigger events #2

lindseydiloreto opened this issue Aug 24, 2021 · 15 comments
Labels
Feature Request New feature or request
Milestone

Comments

@lindseydiloreto
Copy link
Contributor

At the moment, only a current event is supported:

  • On Save Entry

This can (and should) be easily expanded to cover other events:

  • On Delete Entry
  • On Save Asset/User/etc.
  • On Delete Asset/User/etc.

I'm not sure when each particular event will be supported... Feel free to leave a comment if you have a preference! 🙂

@lindseydiloreto lindseydiloreto added the Feature Request New feature or request label Aug 24, 2021
@lindseydiloreto lindseydiloreto added this to the 1.0.0 milestone Aug 24, 2021
@lindseydiloreto lindseydiloreto changed the title Add support for more trigger events 🚩 Add support for more trigger events Aug 24, 2021
@AndrewMac
Copy link

Whatever you do for entries, I'd like to see for Commerce Products, Digital Products and Users. Thanks! :-)

@lindseydiloreto
Copy link
Contributor Author

Noted! 🙂

@aaronmclayton
Copy link

Is on save/entry and publish entry the same? One could save to a draft, and technically save. I'm not sure the controller actions on this in Craft.

@lindseydiloreto
Copy link
Contributor Author

That's a great question. All saved entries will trigger this event, so it's really a matter of filtering to get the behavior that you want...
filters@2x

  • The "Freshness" filter determines whether the entry is brand new (via isNew).
  • The "Drafts" filter determines whether the entry is a Draft or Published.

There are a lot more subtleties and nuances to the "On Entry Save" event, including plenty of stuff that I'm still trying to wrap my head around. It's quite possible that these two filters will evolve into something more significant down the road.

@theurbanu
Copy link

Do you plan on adding the ability to further filter saved new entries, for example, if entry is new AND a specific lightswitch field in enabled?

Another example would be if the status of a entry is changed from pending to enabled, can an email be sent to the author of that entry?

@lindseydiloreto
Copy link
Contributor Author

"... if entry is new AND a specific lightswitch field is enabled"
"... if the status of an entry is changed from pending to enabled"

The very short answer is "yes". All of those features are on the roadmap. 🙂

The longer answer... as a workaround, you can take advantage of these two existing features to achieve your goals...

  • skipMessage - Within the context of a Twig message, you can create simple "yes/no" logic. If the conditions fail any of your tests, you can easily skipMessage and move on to the next one.
  • Automatic variables - These variables will automatically be available in your Twig templates. You can use them to determine whether or not to skipMessage.

Here's some rough pseudo-code...

{% if entry.myField != 'value that I want' %}
    {% skipMessage %}
{% endif %}

"... can an email be sent to the author of that entry?"

Yup, absolutely! When editing the Message in the control panel, select Custom > Users and specify the author of each Entry.

{# Encode the Entry author's ID #}
{{ [entry.author.id]|json_encode }}

^ Fair warning, we may change the "Custom" behavior before 1.0 is released. Handling this logic in Twig is complicated and clunky, we may move the customization logic into PHP.

@mach1media
Copy link

Agreed with @AndrewMac - Whatever you do for entries, I'd like to see for Commerce Products, Digital Products and Users. 😃

@lindseydiloreto lindseydiloreto pinned this issue Sep 30, 2021
@lindseydiloreto
Copy link
Contributor Author

Just got another vote for User events and Solspace Calendar events.

Hoping to get to this soon (for anyone following this thread). 🤞

@lindseydiloreto
Copy link
Contributor Author

+1 request for the "on save user" event (per @darylknight).

@johnj24
Copy link

johnj24 commented Sep 15, 2022

Lindsey, is an asset upload trigger possible from a front-end user form?

@lindseydiloreto
Copy link
Contributor Author

@johnj24 I believe so. You want a trigger for when the file is uploaded (not when the Asset is saved).

Is that correct?

@johnj24
Copy link

johnj24 commented Sep 20, 2022

@lindseydiloreto I guess ideally both, but for now I think all I'm looking for is on upload. I have a client looking to be notified when a user uploads a file through a front-end form. The user does not have the ability to save any file changes beyond that, if that's what you mean?

@jl-digital
Copy link

I'd like the event to only fire on the set post date and time. If I set the post date of an entry in the future, the email will be sent on entry save, not on entry postdate. But the entry is not yet visible on the front end.

@timprint
Copy link

I am currently using Percipio's "Notifications" plug-in but the Craft 3 version is incompatible with PHP 8.1 and 8.2. I am looking for an alternative.

I am using it to send emails to users when they are added to specific user groups.

For example: "You're membership has been approved, your discounts will automatically be applied at checkout" when an admin manually adds them to a specific user group.

Is that a possibility for v.1 ?

@lindseydiloreto
Copy link
Contributor Author

Hi @timprint, great question. Yes, that feature will definitely be possible in v.1. 👍

I've been doing a lot of work on v.1 lately, there have been some significant changes since the original beta version. Feel free to ping me on Discord if you want to get a sneak peek!

@lindseydiloreto lindseydiloreto unpinned this issue Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants