Questions tagged [events]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
15
votes
4answers
3k 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/...
10
votes
2answers
1k views

Booking paid-for events: How?

First off, I appreciate this is open ended and SE isn't the best place for it. For a lack of a better place to ask though, here we are: I've just built a system for a client where users could sign up ...
8
votes
2answers
2k 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....
6
votes
2answers
298 views

Delete / change Status from CP via Ajax (trigger event)

In a plugin init function I'm listening to entries.saveEntry and entries.deleteEntry. This works perfectly if I'm editing entries from their detail view. If I 'bulk' change or delete entries, these ...
5
votes
1answer
1k 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 ...
5
votes
1answer
654 views

Can a plugin fire a custom event?

I have PluginA that needs to listen for something that PluginB does. PluginB needs to include a Model in the event data so that PluginA (and any other subscriber) can pick that up and do whatever it ...
4
votes
2answers
2k 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, ...
4
votes
2answers
722 views

How do I extend another plugin?

I'd like to know if it's possible to extend another plugin with my own. I'm currently using the Sprout Forms plugin to create a contact form on our website, and I would like to extend that so when a ...
4
votes
1answer
316 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 / ...
4
votes
1answer
683 views

How do you raise/fake an event so that you can test handlers listening for it?

We use event integration (native and custom) in a lot of the plugins we build and I was wondering if anyone has come up with a simple way to raise those events at will, without having to follow a ...
4
votes
1answer
262 views

How do I stop an element from populating?

I have an event listener on elements.onPopulateElement, what I want is make a last minute decision if I want to populate or not. I have certain customfields on an admin CP user (eg company). All ...
4
votes
2answers
514 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 ...
4
votes
2answers
85 views

Is it possible to detach event listeners?

I've got an event listener hooked up like this: craft()->on('elements.populateElement', array($this, 'onPopulateElements')); Is it possible to detach/deregister the listener? E.g. something like ...
4
votes
1answer
275 views

Is it possible to listen for Yii events?

I want to listen for Yii events like onBeginRequest and onEndRequest. I've tried the following but nothing happens :( \Yii::app()->onBeginRequest = create_function('$event', 'die ("YO") ;'); and ...
4
votes
0answers
794 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 ...
3
votes
2answers
328 views

Is there a way to detect if a action is triggered from a control panel form?

We're building a content platform for a bank for a client of us. One required feature lets relationship managers add clients (members) to the platform which get assigned a specific group. We listen ...
3
votes
2answers
467 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 ...
3
votes
2answers
236 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 ...
3
votes
2answers
147 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 ...
3
votes
1answer
357 views

Programatically change a lightswitch value on an entry on save

I have a simple plugin that fires some events entries.onSaveEntry based on if a lightswitch is turned on with that entry. What I would like to do as the last event in my plugin would be updating the ...
3
votes
2answers
161 views

Show events until Midnight

I have a list of events which should list each event until midnight of said day. So If a gig happens at 17:00 it should still be visible until midnight of the same day. I came relatively close (I ...
3
votes
1answer
193 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,...
3
votes
1answer
120 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(...
3
votes
1answer
117 views

How do I access the properties of an object which triggered an event?

I'm trying my first plug-in; it's to automatically create an entry in a section when a user belonging to a specific user group is activated. However I'm not that hot at PHP and I can't figure out how ...
3
votes
1answer
192 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 ...
3
votes
1answer
695 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 ...
3
votes
1answer
69 views

Getting PHP error when trying to bind to onEditionChange event

I'm trying to bind to the onEditionChange event with something like this: craft()->on('onEditionChange', function (Event $event) { craft()->womb->sendEvent($event); }); However, i'm ...
3
votes
2answers
69 views

How can i detect that an asset has been published from a plugin?

So, i must write this Craft plugin to index documents as soon as they are published, though a special publication field used amongst different pages templates (including a matrix field !). How can i ...
3
votes
1answer
80 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?
3
votes
1answer
95 views

Create event before site loads

I want to create an event that triggers before the site loads to I grab the variables passed in the http header and send them to a plugin I have made. I will have a url like http://www.foo.com?...
2
votes
2answers
87 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 ...
2
votes
1answer
194 views

Calling an event from a third party plugin in my plugin

Trying to work out if I’m doing something wrong with catching an event from another plugin in my plugin. I’m trying to use amforms “onSaveSubmission” event, so, in my plugin’s init() function i have ...
2
votes
1answer
517 views

Entries where field = current month?

I'm trying to pull entries from an events channel where a date field falls in the current month. Through google and other SE posts I've gotten to the following code: {% set currMonth = now|date('m') ...
2
votes
1answer
249 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 ...
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 ...
2
votes
2answers
303 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
2answers
410 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 '...
2
votes
1answer
126 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 ...
2
votes
1answer
137 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 ...
2
votes
1answer
71 views

Is there a JS event triggered when a new widget is created?

Pretty straightforward problem... On the dashboard, I click "New Widget". I select "My Custom Widget" type. A new instance of "My Custom Widget" appears on the dashboard, ready to be edited. How can ...
2
votes
2answers
967 views

How can I pass variables to email's template onBeforeSendEmail

I'm trying to add some variables to email's template to be rendered before email is sent. I was able to modify emailModel like customHeaders and subject but I couldn't pass custom variables to the ...
2
votes
1answer
167 views

ajax call breaking onBeforeSaveUser

I have a plugin that has an onBeforeSaveUser event. This fires the mailchimpsubscribe plugin to subscribe users to selected newsletters. Everything works correctly the user is subscribed and then the ...
2
votes
1answer
119 views

How do I get a list of craft provided events at runtime?

The documentation provides a very comprehensive list of events provided by Craft but I would like to know if there is a way to get a list of those events at runtime. Having such list would enable me ...
2
votes
1answer
19 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 ...
2
votes
1answer
123 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 ...
2
votes
1answer
118 views

Plugin add options to entry edition

What I'm trying to do is add two checkbox in the entry edition page, just under the dates or special notes, somewhere here : Then if the checkbox is checked, I check it with an event and perform an ...
2
votes
1answer
352 views

How to use onDeleteEntry?

I currently have a plugin which needs to do things on save and delete entry events. My save entry code is all working perfectly but the onDeleteEntry code doesn't ever fire when I delete an entry. I ...
2
votes
1answer
299 views

Accessing the raw post data from an $event

My users have an accountBalance field and there's a createInvoice service in my plugin. I'd like to autogenerate an invoice whenever the accountBalance changes (including from the admin cp), while ...
2
votes
1answer
440 views

Setting an entry slug from a pluign

I have a plugin where I'm creating custom entries based on user submitted data. Saving these entries works well. As does modifying their titles after saving to add the entry's ID to the title (using ...
2
votes
1answer
876 views

Issues with Twig template includes when rendering from a service called from a CP-triggered event

I have a listener for the entries.saveEntryevent that is calling a service, which generates an email from a rendered template. The template is attempting to import macros. MyaddonPlugin.php::init() ...