I need to build a plugin or module that hooks into the Sprout form upload file function so I can add text programmatically to the user uploaded filename. I've had input before that I should work with the hooks that Sprout provides. However, I am newish to how Craft 3 functions and I am not familiar with how hooks work. Can anyone please direct me to any tutorials or education sources that explain how hooks work? Are they a basic, inherent process of plugin development? I've only been able to find a tiny bit of documentation on hooks regarding Craft 2.

1 Answer 1


First I think it helps to clear up some terminology... I've seen a few devs (myself included sometimes!) using the word "hooks" when they really mean "events". For me at least this is a hangover from Craft 2 (and also ExpressionEngine), where "hooks" were used to inject custom back end code.

In Craft 3 however, everything is driven by events. Plugins/modules listen for these events and take action accordingly. ("Hooks" in Craft 3 are something different - more specifically, "Template Hooks" simply give you a chance to alter Craft's control panel templates and inject your own front end code).

Craft and the underlying Yii framework both fire hundreds of different events before and after every conceivable thing that happens, and likewise, plugins can do the same.

So to code a plugin/module that listens for events from Sprout Forms, you'd approach this in exactly the same way as a regular Craft plugin/module. Here's the general syntax for listening to Sprout's events: https://sprout.barrelstrengthdesign.com/docs/forms/events-and-hooks.html#events - in your case you'd probably want to listen for Sprout's EVENT_BEFORE_SAVE event and amend the POST data accordingly.

  • Thank you so much for clearing that up! Commented Aug 13, 2020 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.