Questions tagged [events]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
12 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 ...
1
vote
1answer
23 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,...
0
votes
0answers
20 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 ...
0
votes
0answers
7 views

trigger javascript when block is added to matrix or supertable

I need to run javascript to modify a field-input when the user edits an entry and adds a block/row to a matrix or super-table field. Is there an event to listen on or some callback to hook in? ...
3
votes
1answer
93 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
119 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
27 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
63 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
31 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
22 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
35 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
37 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
55 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 ...
6
votes
2answers
762 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
3answers
262 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
137 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
15 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
81 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
644 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
218 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
85 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
35 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
115 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
40 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
37 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
170 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
2k 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
168 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
137 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
207 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
208 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
83 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
280 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
225 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 ...
2
votes
0answers
72 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
37 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
65 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
222 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
72 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
731 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
109 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
86 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
89 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
388 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
338 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
62 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
240 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 ...