Questions tagged [events]
The events tag has no usage guidance.
22
questions
14
votes
3
answers
2k
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 ...
6
votes
2
answers
369
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 ...
4
votes
2
answers
261
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 ...
2
votes
1
answer
3k
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
2
answers
966
views
How to log info from an onSaveEntry event?
Having problems logging to the console using log from within an onSaveEntry or onSaveUser event. Just a simple test below, but will be critical for error logs.
public function init()
{
parent::...
15
votes
4
answers
4k
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
2
answers
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 ...
5
votes
1
answer
843
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 ...
5
votes
2
answers
2k
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 ...
5
votes
2
answers
3k
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 ...
4
votes
1
answer
323
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
1
answer
875
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 ...
3
votes
1
answer
409
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 ...
2
votes
1
answer
439
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
1
answer
170
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
1
answer
772
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 ...
2
votes
1
answer
188
views
What is the best way to handle Events that get triggered during a migration?
We have a Form plugin and an Email plugin. Users can setup the Email Plugin to send off notification emails when a particular Event happens. Some users setup a notification email to be sent when a ...
2
votes
2
answers
1k
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 ...
1
vote
2
answers
515
views
Rename a file using onSaveEntry event
craft()->on('entries.saveEntry', function(Event $event)
{
// entry slug, will be used as image name
$EntryTitle = $event->params['entry']['slug'];
// Get attached image
$entry = ...
1
vote
1
answer
275
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()-&...
1
vote
1
answer
155
views
Handling Endless Recursion in saveEntry?
I'm trying to update the expiry field—based on an existing field (in this case classDate)—as soon as an entry is saved.
Based on this answer, the clever recursion code in carlcs' Auto Expire plugin, ...
0
votes
0
answers
327
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 ...