Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [events]

The tag has no usage guidance.

1
vote
0answers
11 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
20 views

EVENT_AFTER_SAVE_ELEMENT fires twice for some weird reason

Any idea why this code is always fired 2 times every time I save my entry? I get the same thing with Elements::EVENT_BEFORE_SAVE_ELEMENT (only for test purposes as I need to trigger AFTER), same thing ...
0
votes
0answers
27 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
19 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
20 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
59 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 ...
1
vote
1answer
331 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, ...
1
vote
1answer
396 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 ...
0
votes
0answers
37 views

Craft 3 best practices events on pageload and unload

I need to find solution for the following use-case I need to eagerload some element on pageload, so I would like to write a common logic which is doing this. I do not want to put this logic into the ...
1
vote
1answer
27 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
106 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
80 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
111 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
168 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
68 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 ...
0
votes
0answers
29 views

Event handler priority between multiple plugins [duplicate]

So I've got two custom plugins I'm developing for a project, and they both listen to craft()->on('saveUser') in their respective init() functions. The problem I'm running into is I need one of the ...
1
vote
1answer
181 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
151 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
60 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
29 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
55 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
163 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 $...
4
votes
1answer
51 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
533 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
96 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
75 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
69 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 ...
3
votes
1answer
282 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
190 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
49 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
154 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
116 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()-&...
4
votes
1answer
575 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
295 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 '...
0
votes
1answer
233 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 ...
3
votes
2answers
105 views

Fire event first time future dated entry goes 'live' from 'pending'

Is there a way I can run some code from a plugin when a future dated entry goes 'live' from 'pending'? I am trying to send an email update that a new entry has been posted. The related post below ...
1
vote
1answer
40 views

How should a multi-stage editorial process be implemented in Craft?

I'm building an editorial system on Craft which has 6-8 editorial stages, such as Assignment, Initial Proofing, Secondary Proofing, etc. It seems that the simplest solution would be to have the ...
3
votes
1answer
64 views

'onDeleteEntry' Event is not triggered when an Entry is deleted?

I have the following code: namespace Craft; class AffiliatesExportPlugin extends BasePlugin { //All other functions public function init() { craft()->on('entries.onDeleteEntry', function(...
2
votes
1answer
17 views

Close entry editing after set time (for certain a user group)

I have a group of users who are allowed to create entries and edit them but I want to put a window on how much time they have in which they can edit it. For example, after initial submission they ...
1
vote
1answer
89 views

What does the Before compile event inside the Contact Form plugin do?

I see there is an undocumented event called onBeforeMessageCompile in the Contact Form plugin source: Craft::import('plugins.contactform.events.ContactFormMessageEvent'); $event = new ...
1
vote
1answer
134 views

Sprout Forms `onSaveEntry` event

I need to add an event handler for the onSaveEntry event in order to integrate with another system. In the admin screens for the form where and how do I add this event handler?
16
votes
4answers
2k views

Events calendar for Craft - which one should I use?

The current state of events/calendars in Craft is: Calendars - https://topshelfcraft.com/calendars/introduction Venti - http://tippingmedia.com/venti Solspace Calendar - https://solspace.com/craft/...
2
votes
1answer
101 views

Checking for first time an entry is “published” i.e. saved with a Live status

Is there a way, via an Event or otherwise, to catch the first time a post is saved and isn't in disabled mode? I want to send out an email alert to users when a new entry is published, but I want it ...
3
votes
2answers
148 views

Best Method of Handling Repeated Content Within Existing Fields?

We are trying to find the best solution for handling repeated content within existing Fields in the CMS. That is, there are bits of information which could be used nearly anywhere within existing ...
2
votes
1answer
104 views

`onBeforeSaveUser` - Access existing user data

I'm trying to run a quick check to see if any of my user's data has changed before saving them. However, I'm running into a situation where I can only access the new data. I can't tell if this is a ...
3
votes
1answer
572 views

Craft Commerce: How to manage different prices with one product?

I am looking for a solution that would allow me to sell events tickets within Craft. I'm am currently making a prototype with Craft Commerce plugin for this project, but I am already facing a major ...
5
votes
1answer
208 views

Set execution order of plugins listening to same event

I have 2 separate plugins that listen to same event. Now I want to make sure Plugin B starts its action only after Plugin A has finished its job. Is there a way in Craft CMS to set priority / ...
5
votes
2answers
376 views

Is there a way a plugin can watch for live preview updates?

I'm working on a site that involves taking a URL and then getting information about that URL using an API. The URL is entered into a field in a Matrix block, and then another field in the same Matrix ...
2
votes
2answers
81 views

How do I access an asset field in the 'onSaveEntry' event?

I'm listening on an entries save event with: craft()->on('entries.saveEntry', function(Event $event) { //$event->params['entry']); -> passes to function }); How can I assess assets that ...
3
votes
1answer
99 views

Plugin using event listener throws error using $this

I have written a plugin to hook into an event raised by a contact form plugin. I am running PHP 5.6 locally, and the plugin works just fine. Moving the code to a server running 5.3 (which I cannot ...