I will show you how to cleanup the image files that the Really Simple Captcha plugin creates.

The plugin creates security captcha image files inside wp-content/plugins/really-simple-captcha/tmp/ directory. This directory may become very large and full of image files if you don’t remove them or clean them up accordingly. These image files can cause high innode usage on your hosting/server.

How to Use Really Simple Captcha in Plugin or Theme

First, you may want to read the How to Use Really Simple Captcha Plugin in Your Plugin or Theme article. The article shows you how to integrate the Really Simple Captcha plugin in your plugin or theme to display a security captcha image, take an input from a user and then do a check to see if the correct code was filled in.

Removing Really Simple Captcha Plugin Images

There are two ways of cleaning up Really Simple Captcha plugin images.
I would recommend that you implement both if possible.

1. Removing Images in Realtime

Once you’ve integrated Really Simple Captcha plugin and you run the check() method, you can run a remove() method to remove the specific image that was generated and used. It’s as simple as that really.

2. Running Regular Cleanup of Images

To do a regular cleanup of Really Simple Captcha plugin images, use the cleanup() method.

It cleans up images older than 60 minutes and will clean up a maximum of 100 images per execution so that it doesn’t consume too much of your server’s resources.

You can do this manually where ever needed or you can actually setup a WordPress cron job to do this for you hourly, twice daily or maybe daily? Let me give you quick code on how to create a WordPress cron job that runs the Really Simple Captcha plugin cleanup() method daily. Do this using wp_schedule_event() and hook to that event.

Run this code to create the WordPress cron schedule. It will then keep running until removed by you manually. And keep the code active such as in your plugin’s core or in your theme’s functions.php file so that it can keep hooking onto the hook.

That’s it, you’re all done! With the previous article linked and this one you have all the needed code and information to integrate Really Simple Captcha plugin into your WordPress site’s plugin or theme using your own code.

Enjoy it and please comment below if you have any questions or suggestions.