Questions tagged [events]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
23 views

Feed Me Plugin - Prevent Feed from Being Triggered Multiple Times in Quick Succession

I’d like to prevent a feedme feed from running more than once when multiple requests are received within a few seconds of each other. My first guess is that I would want to target an event such as ‘’’...
user avatar
1 vote
1 answer
45 views

Check user data before login - Events on Craft3?

I need some help with my login process, it's working but I feel it's not the best approach to achieve it I have the following workflow for the Login process : 1- enter username/password -> press ...
user avatar
  • 115
1 vote
1 answer
40 views

Event triggered when Craft sends email

Is there an event that would be triggered every time email is being sent by Craft? So email message can be intercepted.
user avatar
  • 1,185
4 votes
1 answer
30 views

Identify event origin (e.g. via admin vs module code)?

When using Craft Event triggers in PHP (e.g. Event::on), is there any event metadata that can tell where the event originated from? E.g. if it was triggered from an admin action, or if it was ...
user avatar
  • 408
1 vote
1 answer
32 views

What's the attribute of a Matrix field to add error message

I try to validate some fields before saving the entry, if the field is invalid, prevent the entry from saving and return the error message, I'm doing it via Element::EVENT_BEFORE_SAVE event. It works ...
user avatar
  • 27
1 vote
1 answer
47 views

Manipulating search event

Looking at a means to perform subqueries against certain searches in the back-end of the Craft CMS eg for searches against particular sections within Admin > Entries. Looking into this it seems ...
user avatar
  • 1,711
1 vote
1 answer
36 views

Craft Event Date Range in Craft

I'm creating a date range where I only want to show upcoming events in the next 30 days based on a start date. I have created my query but when I add my if statement to filter on the start date it ...
user avatar
  • 1,097
2 votes
1 answer
54 views

Asset upload hangs when uploading to asset field in entry

I wrote the following code in Module.php that checks if a file size is too large during an asset upload (the file size limit and asset volume handles are defined in a globals: a table with one column ...
user avatar
2 votes
1 answer
82 views

Update matrix block field before saving entry

I have a custom module, on EVENT_BEFORE_SAVE I am looping through a matrix field, this matrix field has a block which has an entry field, a number field and a lightswitch (to know if this block has ...
user avatar
  • 419
1 vote
1 answer
77 views

UrlManager::EVENT_REGISTER_CP_URL_RULES event not firing in custom plugin

I'm working on building out a custom plugin for Craft 3 to create a new element type called Events. Following the Craft docs for creating edit pages, I hit the point where I'm trying to register my ...
user avatar
  • 111
11 votes
3 answers
684 views

How do we distinguish between a 'New' and 'Updated' Live Entry using the craft\elements\Entry::EVENT_AFTER_SAVE event?

I can't decide if I'm missing something or this should be a bug. With the recent changes to Drafts/Revisions in Craft 3.7 it's not clear to me how to distinguish between New and Updated Entries using ...
user avatar
  • 13.2k
1 vote
1 answer
112 views

Craftcms 3 Module - API call validation (on EVENT_BEFORE_SAVE, EVENT_BEFORE_VALIDATE, EVENT_AFTER_VALIDATE, EVENT_AFTER_SAVE)

I am trying to validate entries on Save in a Module. My specific use case requires that the Entry validation - on failure to validate will return user to form with field errors. On successful ...
user avatar
1 vote
1 answer
97 views

How would I detect whether an entry's asset field has been updated on save?

We need to send a notification email when an entry's asset field, Custom Image, has been updated on entry save. We're able to do this consistently for text fields but I'm having trouble doing the same ...
user avatar
  • 438
1 vote
1 answer
59 views

Listening for Change at Entry Save

I want to send an email if/when an entry is saved with a lightswitch switched on after previously being off. I have the below code in my plugin's init file, but I don't know how to check for the ...
user avatar
2 votes
1 answer
77 views

Apply custom filter on the entries in admin control panel using custom plugin in craft cms 3.5

I was referring to Filter entries in the CP based on custom permission and Filter entries in the CP based on custom permission It seems onBuildElementsQuery was available only in 2.x. Is there any ...
user avatar
  • 41
1 vote
2 answers
36 views

Multiple Listeners (Handlers) on Event

Is it possible to register multiple EventHandlers? I mean something like this: Event::on( Entry::class, Entry::EVENT_AFTER_SAVE,[ NotifyWhenCookPostedArticle::handle, ...
user avatar
  • 235
1 vote
1 answer
178 views

Hook into Entry::EVENT_AFTER_SAVE when user saves it

I want to send a Mail to an admin, whenever a User of group ‚Cook‘ creates an Entry of Type ‚Recipe‘. For that I created an Event reacting on Entry::EVENT_AFTER_SAVE : Event::on( Entry::class, ...
user avatar
  • 235
1 vote
1 answer
29 views

Email notifications solspace calendar

I'm considering the Solspace Calendar plugin for a project. Can the plugin send automatic e-mail notifications when an event has been submitted from the front-end? Can the plugin save events ...
user avatar
  • 105
4 votes
1 answer
276 views

Is there a way to compare what has changed on an entry while it's being saved?

I'm taking my first baby steps into the php side of Craft, and my php experience in general is extremely fledgling. But I'm pretty much forced to create a module for a project I have, so here I am ...
user avatar
  • 273
1 vote
1 answer
94 views

Parent are not set anymore after saveElement()

In this code I try to create a new Entry and set a Parent to it. The sectionId and the typeId are actually the same. $navigationItem = new Entry(); $navigationItem->typeId = 4; $navigationItem->...
user avatar
  • 235
1 vote
1 answer
23 views

Stop image upload if moderation fails using EVENT_BEFORE_HANDLE_FILE

I have a frontend form where images can be uploaded. I am handling the image moderation within EVENT_BEFORE_HANDLE_FILE on the Asset class. I am setting session errors for any moderation issues ...
user avatar
  • 419
1 vote
1 answer
224 views

EVENT_BEFORE_SAVE event not getting $entry-id when creating an entry

I don't know if it was with Craft 3.5, but did something change slightly when using the EVENT_BEFORE_SAVE event? I have a simple use case where I am encoding the entry ID and updating the slug when ...
user avatar
  • 419
1 vote
1 answer
69 views

How to differentiate EVENT_BEFORE_UPDATE_SUBSCRIPTION events in Commerce 2/3

I'm listening for various subscription events to send emails to members. Right now, I'm dealing with subscriptions where a renewal payment fails. I'm specifically listening for ...
user avatar
1 vote
1 answer
46 views

Accessing Commerce ‘Product Fields’ in events hooks

I've added an Entries field called linkedCourseEntry to a Product (Product Type > Product Fields tab). In the Product itself I've assigned an entry. I need to access linkedCourseEntry from one or ...
user avatar
1 vote
2 answers
282 views

Commerce: Remove tax adjuster from line item in plugin

I need to remove adjusters from each line item if a certain condition is not met. I see that in the CP you can manually remove them by editing the line item but hunting down this code in Commerce's ...
user avatar
  • 1,887
1 vote
1 answer
27 views

Do Freeform Events Fire From Control Panel?

It appears to me that Freeform Submission events do not fire when editing events in the control panel. They certainly fire from a front-end submission. That would make this statement in the ...
user avatar
1 vote
1 answer
39 views

Do something on save of an entry

if that entry is in a particular section, then I want to do some task. I can't really find the event docs I need to do that. Everything I've come across has been for Craft 2. Any steps for a hint?
user avatar
  • 1,713
1 vote
1 answer
184 views

Update entry Enabled value based on field value when saving

I am trying to update the value of the entry enabled field depending on a certain field value. I am listening to the EVENT_BEFORE_SAVE event and have it updating as such $entry->enabled = $status =...
user avatar
  • 419
1 vote
1 answer
251 views

Event when an entry is enabled

I've been looking for an event that get triggered when an entry is moved from a disabled to enabled status. Currently I'm trying to find it through the EVENT_AFTER_SAVE_ELEMENT event but I have no ...
user avatar
1 vote
1 answer
570 views

Choose not to save an element on EVENT_BEFORE_SAVE_ELEMENT

I want to do some server side checks to see if the entry should be saved or not. In my plugin I have something like that Event::on( Elements::class, Elements::EVENT_BEFORE_SAVE_ELEMENT, ...
user avatar
  • 545
1 vote
1 answer
51 views

How should we be setting up product categories/sub-categories?

New to Craft CMS and currently don't understand the terminology or how things work together in the platform yet. If I want to set up a category structure like the below in Commerce, how is the best ...
user avatar
  • 135
1 vote
1 answer
471 views

EVENT_BEFORE_SAVE_ELEMENT Saving element loop in task/queue

I'm calling EVENT_BEFORE_SAVE_ELEMENT to trigger a task that then updates the entry, but it's causing a loop? The event is triggered when a specific entry type is saved: Event::on( Elements::class,...
user avatar
4 votes
0 answers
308 views

User Event before Login - check if user has password and logged in before

Is there a User Event before the authentication is fired? I want to show a message if the user doesn't have a password yet and if it's his first login / check if he never logged in before - All in ...
user avatar
3 votes
1 answer
321 views

How to determine source of Elements save event

We need to send notification emails when entries of a particular type are created, updated, or enabled/disabled. The entrypoint for this happens in a module's init() method: Event::on(Elements::class,...
user avatar
  • 438
3 votes
2 answers
1k views

EVENT_AFTER_SAVE_ELEMENT triggered twice after saving an entry

I had this weird issue, not sure if that happens to you guys or not. I'm trying to catch the 'after entry is saved' event, using the following code in my custom module's init() function (The module's ...
user avatar
  • 419
1 vote
1 answer
395 views

$event->isNew not working as expected after Craft 3.2 update

Pre Craft 3.2, you could do something like this if you wanted to perform an action in the event you just saved a new entry: use craft\elements\Entry; use craft\events\ModelEvent; Event::on( ...
user avatar
  • 1,887
1 vote
1 answer
52 views

Delete event from front end

I am using Solspace Calendar plugin where front end user can add/edit events. Is there any functionality so that user can delete an event from front-end?
user avatar
1 vote
1 answer
133 views

Solspace Calendar Event Editing

I'm using Solspace Calendar for Craft and I'm currently trying to implement the edit event form. Once a user selects an event on the calendar they are taken to the event page. On this page I have the ...
user avatar
  • 245
9 votes
2 answers
3k views

Events documentation for Craft 3

I've been looking for an Event Reference doc for Craft 3 just like what we had for Craft 2, but couldn't find one. The only events doc I found for Craft 3 is the plugin updating guide: https://docs....
user avatar
  • 419
1 vote
3 answers
1k views

How to change an entry's slug on EVENT_AFTER_SAVE_ELEMENT?

My entries' titles are auto-generated from several fields values on first save. When one of these fields values change, I would like to update the auto-generated slug also: Event::on( \craft\...
user avatar
3 votes
1 answer
246 views

Selling tickets to repeating events with Commerce (and Solspace Calendar?)

We need to build a ticketing system for venue tours, that happen every week within certain date ranges, and with an option to exclude specific dates from the availability list. Looking at Solspace ...
user avatar
2 votes
0 answers
32 views

What are the replacements for the order events onBeforeAddToCart and onBeforeGatewayRequestSend in Commerce 2

I'm looking for replacements for the events onBeforeAddToCart and onBeforeGatewayRequestSend. I used onBeforeAddToCart to prevent the user from adding an article from different article groups to the ...
user avatar
  • 685
1 vote
1 answer
174 views

How to reset a multi-value checkbox using EVENT_AFTER_SAVE_ELEMENT in Craft 3?

I'm porting the functionality of an existing plugin from another CMS into Craft 3 through a custom Craft module. The functionality is: When an option from a multi-value checkbox is checked on the "...
user avatar
2 votes
2 answers
3k views

How to modify and save a field in entry on EVENT_AFTER_SAVE in a plugin?

I'm trying to build my first little plugin. I'm stuck with a problem: I need to modify the value of the specific field reference, right after the saving of the entry because the new value is supposed ...
user avatar
  • 173
1 vote
2 answers
467 views

Live Preview for Upcoming Entries

I have an Events section on my site, and to display upcoming and passed events (entries with a status of pending or expired) I manually set the entry in the template: Where the URL is /events/my-...
user avatar
  • 1,075
1 vote
1 answer
237 views

Modify Order table in Control Panel

I need to add and/or change an attribute in the order table on /admin/commerce/orders. The Order Element itself does not have a EVENT_SET_TABLE_ATTRIBUTE_HTML, and I've tried with variations like ...
user avatar
  • 155
1 vote
0 answers
123 views

Can't set structured entry parentId in BEFORE_SAVE event using field data

I have created an event that is called on beforeSave within my plugin. Code below: Event::on( Entry::class, Entry::EVENT_BEFORE_SAVE, function(ModelEvent $event){ /...
user avatar
0 votes
0 answers
258 views

How to exclude some fields from the searchindex using the RegisterElementSearchableAttributesEvent event?

Context I had big issues on a Craft 2 multilingual site with dozens of thousands of entries that were using Matrix fields. The site had become extremely slow (almost unusable), especially when ...
user avatar
1 vote
1 answer
172 views

Trigger download after form submission

I am working with a contact form plugin, written by an external developer several years ago. I want to trigger a file download upon successful completion of the form. As it stands, I have an onPost ...
user avatar
1 vote
1 answer
91 views

Is there an event that is triggered when an entry expires?

I would like to update an entry after it has expired via a plugin. Is there an event that I can use to do this when using Craft 2?
user avatar
  • 21