Bulk Adding Captchas to WFFM Forms with Sitecore Powershell Extensions

Last week we had some Robots submitting a lot of WFFM forms across the website, creating thousands of submissions. I knew the quickest way to solve this was to add the out of the box CAPTCHA to the forms. However we had to put a solution in place quickly but with over 350 form instances across the website this needed a automated solution.

star-wars-robots-blured

I immediately thought SPE might come to the rescue here (as it often does), so  had a look on Google/SSE etc but couldn’t see anyone else who’d done this. So I fired up SPE and the following script is what I ended up with:

Add a CAPTCHA to all WFFM Forms with SPE

google-recaptcha

The script recursively loops through all the forms in the root folder set in script and checks if a CAPTCHA exists on the form already. If it doesn’t find one, it creates one as the last field in the form using the settings defined in the script. You can easily update any of the field settings to your liking such as the name and if it’s required etc.
It could also be modified to filter forms based on criteria such as name, folder or send/save actions if required too.

I hope this is useful for someone else in the future.

Published by

Adam Seabridge

I am a Freelance Sitecore Developer and 7x Sitecore Technology MVP (2024 - 2018). I have been working with Sitecore since 2013. You can reach me on twitter @billyjava or comment below if you have any questions or feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *