Very new to Craft, so can someone please tell me what class/file I'd add the 'The beforeSend event' code, as I'd like to filter out some spam?

The documentation https://docs.craftcms.com/v2/plugins/hooks-and-events.html#hooks says that the new event listener should be added to the plugins 'init' function, but there isn't one.

many thanks

  • Which version of Craft do you use? 2 or 3. Do you look to any another plugin and copy function structure?
    – lenka
    Oct 15 '18 at 14:07
  • The version is 2.6.3017, I don't know where to put the call to the event code or where the event code should go, I could hack it but I would like to know the correct way?
    – user8844
    Oct 15 '18 at 20:54

Correct way is little bit longer.

Firstly, you need your own plugin, you can generate skeleton here: https://pluginfactory.io/ It's better than rewrite someone else's, because you can't update it after you add a code.

Secondly, you add your beforeSend Event to Plugin class by add it to init function - the function will be generated in step one - it is in the YourNamePlugin php file in root.

If you start a new project, it is better to work in Craft 3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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