1

This is not really specific to Craft, but you should import Craft at the beginning of your class file like this: <?php use Craft; ... I suggest you take a look at that documentation for more details about how to import PHP classes: https://www.php.net/manual/en/language.namespaces.importing.php


1

I don't have much experience with these, but here are some potential plugins you can look into for Craft 2 that use various anti-spam techniques: https://straightupcraft.com/craft-plugins/snaptcha https://straightupcraft.com/craft-plugins/sprout-invisible-captcha https://straightupcraft.com/craft-plugins/google-recaptcha https://straightupcraft.com/craft-...


Only top voted, non community-wiki answers of a minimum length are eligible