Questions tagged [events]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
15 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,...
1
vote
2answers
52 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 ...
0
votes
0answers
22 views

Geocode address when saving custom field type in plugin

I've got a Craft CMS 3 plugin that has a custom field type for entering an address. When saving that field I'd like to take that address and geocode it using Google's Geocode API and save the latitude ...
1
vote
1answer
43 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( ...
1
vote
1answer
22 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?
0
votes
0answers
21 views

Send delete event timestamp element api

I have an endpoint that sets a response header when an entry is saved (code below). Is there a similar method I can use when an entry is deleted? 'api/entries.json' => function() { ...
0
votes
0answers
29 views

How do you register template paths from a module or plugin when a console controller action is called?

When developing Craft 3 plugins/modules, we usually tie into the View::EVENT_REGISTER_CP_TEMPLATE_ROOTS or View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS RegisterTemplateRootsEvent events to register custom ...
0
votes
0answers
35 views

Hooking Event After Record Save

I have a custom module that is receiving data from an external API. I need to save some of that data into a record and return a success response, so far all is good. Along side this I want to set up ...
1
vote
1answer
43 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 ...
3
votes
1answer
442 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....
1
vote
2answers
130 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\...
3
votes
1answer
123 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 ...
0
votes
0answers
13 views

No EVENT_DEFAULT_ORDER_STATUS in craft\commerce\services\LineItems?

The Commerce 2 docs shows LineItems::EVENT_DEFAULT_ORDER_STATUS as a parameter for the event beforeSaveLineItem and afterSaveLineItem, but craft\commerce\services\LineItems did not have a constant ...
2
votes
0answers
20 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 ...
0
votes
1answer
67 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 "...
1
vote
2answers
435 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 ...
1
vote
2answers
174 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-...
1
vote
1answer
61 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 ...
1
vote
0answers
30 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){ /...
0
votes
0answers
88 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 ...
1
vote
1answer
36 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 ...
1
vote
1answer
35 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?
2
votes
1answer
138 views

How to get an entry url from EVENT_AFTER_SAVE_ELEMENT callback?

In my plugin I am registering a callback for Elements::EVENT_AFTER_SAVE_ELEMENT event. Previously, in Craft2, I could access the URL of the saved entry from the $event parameter passed into the ...
4
votes
2answers
1k views

User events in Craft 3

How do I capture user events in Craft 3? I looked at the documentation but couldn't figure it out. I need to capture after user registration events and after user save events. Here is what I tried, ...
2
votes
1answer
1k views

How to saveElement in EVENT_AFTER_SAVE_ELEMENT without infinite loop

I am trying to update an entry's title in a Craft 3 module after an entry is saved. I cannot use EVENT_BEFORE_SAVE_ELEMENT because the title gets updated after this. If I use EVENT_AFTER_SAVE_ELEMENT ...
1
vote
1answer
34 views

Charge Model “amount” and “userId” not always populated

I'm using the onCharge event to populate a separate purchases table that I can query elsewhere (combining both stripe and my other Paypal payments system). The onCharge event is mostly working, but ...
1
vote
1answer
137 views

Confirm Password on Set Password Form

Is there a way to send errors back to the set password form? I am listening to the users.onBeforeSetPassword event in which I want to confirm that the string in a confirm password field is the same ...
1
vote
0answers
125 views

commerce_orders onOrderComplete not triggered?

Problem: I want to trigger an action (Instant Analytics plugin) whenever a payment (Craft Commerce plugin) is successful (webhook). Payment provider is Mollie. So far I created a plugin that listens ...
1
vote
1answer
193 views

Unable to set error message in onBeforeDeleteUser

This is related to How to overrule Craft error messages with custom setError()? but I don't have enough rep to comment on it. I have a plugin that needs to check if a user is ok to be deleted before ...
1
vote
1answer
200 views

renaming a file in onBeforeSaveAsset won't work

I'm trying to rename a file before it is actually saved into Craft, by using the following code snippet in a plugin: craft()->on('assets.onBeforeSaveAsset', function(Event $event) { if($...
1
vote
1answer
78 views

Error when trying to send HTML email on event onActivateUser

Background: I'm working on a site that has frontend registration with some custom fields. The client would like to have a notification email whenever someone activates their account, containing the ...
1
vote
1answer
262 views

How to fire a custom event from another plugin?

I have some questions about events. I want to fire a custom event from another plugin. The event handler is in MyHelpers_PostService.php (plugin A). public function onSavePost(Event $event) { $...
2
votes
2answers
210 views

Modifying entry with 'onBeforeSaveEntry' event

I'm trying to modify a field on an entry before it is saved. What I'm trying to do is use a field from a linked entry to populate the same field on the entry being saved. From logging I know the ...
1
vote
0answers
71 views

Timezone drama for events calendar

Working on site where there is events calendar of conferences and webinars. Users are (literally) all over the world. Trying to figure out how I am going to handle time zones. Factors: - Fields I am ...
1
vote
2answers
35 views

onBeforeDeleteCategory not working / inconsistent

I need to run checks before allowing a user to delete a category. I have added the following code to my main plugin class: craft()->on('categories.onBeforeDeleteCategory', function(Event $event) { ...
1
vote
1answer
64 views

onBeforeSendEmail event triggered from Commerce_EmailsService

I'm trying to access the order and orderHistory model via onBeforeSendEmail event. I can see that in Commerce_EmailsService.php file on line 311 the event is created with those params and passed to ...
1
vote
1answer
208 views

entries.saveEntry not triggered by ResaveElements task

I've got a plugin that does a thing when an entry is resaved. It works great. However I need it to fire for every single entry to build some data. craft()->on('entries.saveEntry', function(Event $...
3
votes
1answer
70 views

Is it possible to create event with multiple date/time (out of box)

I have an event that runs from Monday to Sunday from 9am to 6am but on Thursday the time is from 9m to 8pm. How can I add repeat dates with diffrent time for Thursday?
4
votes
0answers
688 views

How to handle Craft 3 events in a plugin? Element API is returning null data

The below refers to Craft 3 and the Element API plugin for Craft 3. I would like to do something when the Element API plugin fires its onBeforeSendData event, I can see in the controller for element ...
1
vote
1answer
107 views

Venti Calendar URL

I have contacted support and looked in the usual places, it's the weekend so might not be till Monday that I hear back from support. Issue is that I cannot seem to get the URL right when displaying a ...
2
votes
2answers
85 views

What is the benefit of using a calendar event plugin or building your own?

I am looking at purchasing Venti 2 for events and also what it takes to build my own plugin. Does anyone know what kind of time it takes to build a plugin that does reoccurring dates, categories and ...
1
vote
1answer
84 views

Can a plugin manually raise another plugin's Event?

I have created an Adjuster which is attached to commerce_lineItems.onPopulateLineItem. The discount criteria is based on validation of a completely separate coupon API, so I created a permission-less ...
2
votes
1answer
362 views

How to overrule Craft error messages with custom setError()?

I know I can set errors and notices in the CP with setError() and setNotice(). But it gets overruled by the default error message in my event. I have a beforeDeleteEntry event which stops the ...
0
votes
1answer
307 views

How to create custom option/action for backend entry lists

Please excuse me for the title.. I have no idea how to describe my problem better - if someone knows a better description for this question feel free to edit it. I made a screenshot to clarify what I ...
2
votes
1answer
61 views

Get saved content of entry

I hooked up into the content.saveContent event. I want to save the entry content into a different application. Is there a way to retrieve the content as a Json (Or something more friendly). I think do ...
1
vote
1answer
227 views

Trouble calling a plugin's controller function from within an event listener function

I am working on extending the formbuilder2 plugin to call and pass the $event variable to a custom Controller after FormBuilder2 has initialized the "onBeforeSave" event within the FormBuilder2 ...
1
vote
1answer
156 views

entries.onSaveEntry does not fire from frontend

I created my own actionEntrySave for my frontend form. and I'm using the $entryService->saveEntry($entry); method to store my entries into the database.The problem is this does not fire craft()-&...
5
votes
1answer
897 views

Bulk resave entries to trigger onSaveEntry event

I have a site with a hundred+ or so entries. I've added a new field to my entry template, but it won't take effect until it's been activated by a onSaveEntry event. I've gone through maybe 15 ...
2
votes
2answers
348 views

Event Listener for Publishing Scheduled Posts

For performance reasons I'm caching full HTML responses to Redis. This does wonders for response times, but cache invalidation becomes a bit tricky... I'm currently purging the entire cache on '...
1
vote
1answer
257 views

Create Solspace Calendar Event on Commerce onOrderComplete

I'd like to create a Solspace Calendar Event on Commerce onOrderComplete. I've done this with Charge where on Charge Success an event was created however I know that I did that in a less than ideal ...