Events: Check if submission saving was triggered by user sending the form? #1574
-
Hi, I'm currently learning more about the How can I check if this event was triggered by the frontend user submitting the form - and not by a backend user editing the submission data later? ChatGPT recommended that one option is to perform an identity check?
Is there another way to do this in a robust way? Technical background: I trigger an API where I create a new record after the form is submitted. I want to avoid duplicates. Thanks very much in advance! Regards, Matthias |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Checking whether someone is logged in or not isn't an effective way to check if it was a front-end request. One option is to use But, the So you're really safe to use |
Beta Was this translation helpful? Give feedback.
Checking whether someone is logged in or not isn't an effective way to check if it was a front-end request. One option is to use
Craft::$app->getRequest->getIsSiteRequest()
which will let you know if this is a request from the front-end.But, the
EVENT_AFTER_SUBMISSION
isn't fired from saving a submission in the control panel. Formie has two paths when it comes to submissions. There's theformie/submissions/submit
action endpoint that creates a new submission.formie/submissions/save-submission
is for when editing it via the control panel.So you're really safe to use
EVENT_AFTER_SUBMISSION
to enact on a form being submitted. This is what email notifications and integrations use to trigge…