Closed rtgoodwin closed 3 years ago
If this is as intended, I wonder if there is a good way to grab the element data and do the same query FeedMe does to detect the duplicate entry (given I know the criteria). Thanks!
I think that for this to work with FeedMe you need to use the Element service after-save event.
Be sure to check that the saved element is an instance of Submission
before doing what you're doing.
Wouldn't the element be a (Solspace) Calendar Event
element? In my messing around I couldn't quite tell what the element attached to the FeedMe event was, but I think it was one. (Though perhaps with the core Element event save it would be different?). My flow is:
Yes, sorry, I thought this was in the freeform repo 😬
I wanted to also mention that if you were to use Freeform, you could create Calendar events automatically with a simple form element connection configuration.
@gustavs-gutmanis Noted :) I have paid for Sprout Forms, then Formie which had some features I really liked, and so moving to Freeform would be yet another move (although as you point out, would make this particular thing much easier :) ). I can consider it though! What I'm trying to do is let users submit an event, without directly writing to the Calendar. The form of course is a means to do that, though I looked at Front End editing/submission and thought perhaps I could make a "secure enough" way for guests to do that...perhaps not :)
Ultimately this particular plugin was simply to send a mail to the submitter if their form submission made it to an actual new enabled Event (Event isNew and Event->enabled), because I have FeedMe set to Enable the Event if certain criteria are met (which I manage through a transform in Element API between the Entry and FeedMe). Does that make sense? And we can close this issue if needed, though I would like to verify the event you mention above first.
Actually installed FreeForm and looked and see that you CAN hook the submission before save and change it, but saw the note about limitations of using the Submission->Event integration (specifically no recurring events).
If I hook the Submission before save (thus before the Event creation) could I (at my own risk!) parse and insert a recurrence rule to the Event? The source code for the Connection doesn't seem to allow it currently, but maybe there's another way?
I'm trying to not have to query and edit the Event entry if possible (and deal with queuing etc); I just don't know if Freeform->Calendar pipeline would prevent me doing that in a meaningful way.
Glad you tried it @rtgoodwin,
There is an event which happens right before an element connection is made, here's the documentation link.
You could hook into that and do your adjustments to the Event
element there and it will get saved right after with your changes applied.
Closing as answer was provided :)
I wrote a small module to hook into Event save events, which works fine when using the CP, but does not seem to fire/activate EVENT_AFTER_SAVE when FeedMe creates/updates an element. My goal is to be able to detect the same action (and isNew) in both cases.
Steps to reproduce
Expected behavior
Able to catch event save/update in the same fashion both ways.
Craft & Plugin Info (please complete the following information):
Additional context