<p>First I think it helps to clear up some terminology... I've seen a few devs (myself included sometimes!) using the word &quot;hooks&quot; when they really mean &quot;events&quot;. For me at least this is a hangover from <a href="https://craftcms.com/docs/2.x/plugins/hooks-and-events.html#what-s-the-difference" rel="nofollow noreferrer">Craft 2</a> (and also ExpressionEngine), where &quot;hooks&quot; were used to inject custom back end code.</p>
<p>In Craft 3 however, everything is driven by <strong>events</strong>. Plugins/modules listen for these events and take action accordingly. (&quot;Hooks&quot; in Craft 3 are something different - more specifically, &quot;<a href="https://craftcms.com/docs/3.x/extend/template-hooks.html" rel="nofollow noreferrer">Template Hooks</a>&quot; simply give you a chance to alter Craft's control panel templates and inject your own front end code).</p>
<p>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.</p>
<p>So to code a plugin/module that listens for events from Sprout Forms, you'd <a href="https://craftcms.com/docs/3.x/extend/" rel="nofollow noreferrer">approach this in exactly the same way as a regular Craft plugin/module</a>. Here's the general syntax for listening to Sprout's events: <a href="https://sprout.barrelstrengthdesign.com/docs/forms/events-and-hooks.html#events" rel="nofollow noreferrer">https://sprout.barrelstrengthdesign.com/docs/forms/events-and-hooks.html#events</a> - in your case you'd probably want to listen for Sprout's <code>EVENT_BEFORE_SAVE</code> event and amend the POST data accordingly.</p>

CC BY-SA 4.0
2020-08-13T10:25:09.500Z
Thank you so much for clearing that up!
JJefferyDev
CC BY-SA 4.0
2020-08-10T10:22:43.197Z
2020-08-10T10:22:43.197Z
James Smith
<p>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.</p>

<craft3><plugins><plugin-sproutforms><hook>
Help understanding hooks
# Help understanding hooks

(Asked by: username_0 on 2020-08-09)

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.

**Tags:** craft3, plugins, plugin-sproutforms, hook


---

## 1 answers

### Answer by username_1 on 2020-08-10. Score: 3

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](https://craftcms.com/docs/2.x/plugins/hooks-and-events.html#what-s-the-difference) (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](https://craftcms.com/docs/3.x/extend/template-hooks.html)" 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](https://craftcms.com/docs/3.x/extend/). 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.

> **Comments:**
> **username_0**: Thank you so much for clearing that up!  

---

