Console Commands
Freeform includes several console commands to allow you to run cleanup tasks and other tasks.
Resave Submissions4.1.16+
If you need to resave all Freeform submissions, you can do so with the following CLI command: ./craft freeform/submissions/resave. Most of the arguments available to Craft's resave/entries command are available here too, so if you need to also update the Craft Search Index, be sure to add --update-search-index.
./craft freeform/submissions/resave --update-search-index
Purge Commands
Purge SubmissionsPro
Allows you to purge all submissions older than a specific number of days. Freeform automatically attempts to execute this service based on the specified number of days for the Automatically Purge Submission Data setting.
./craft freeform/purge/submissions --age-in-days=30
Purge Spam
Allows you to purge all spam submissions older than a specific number of days. Freeform automatically attempts to execute this service based on the specified number of days for the Automatically Purge Spam Submissions setting.
./craft freeform/purge/spam --age-in-days=30
Purge Unfinalized Assets
Allows you to purge all unfinalized assets older than a specific number of minutes. Freeform automatically attempts to execute this service every 3 hours by default.
./craft freeform/purge/unfinalized-assets --age-in-minutes=180
Field Commands
Find Unused Fields4.1.26+
This command will find all Freeform fields that are not used by any forms on your site. This may be helpful when preparing your site to upgrade to Freeform 5+.
./craft freeform/find-unused-fields
Create Fields
Allows you to create new fields from the command line.
--label="My Field"- the name of the field to be created. Handles will automatically be converted as camel case to match, e.g.myField.--iterations=5(optional) - the number of fields you'd like created as this type and set. Additional fields will be automatically suffixed with numbers, e.g.My Field, My Field 1, My Field 2.--type=select- the field type you'd like the new field to be created as. Options are:checkboxcheckbox_groupdatetimedynamic_recipientsemailfilefile_drag_and_drophiddeninvisiblemultiple_selectnumberopinion_scalephoneradio_groupratingregexselectsignaturetabletexttextareawebsite
./craft freeform/fields/create --label="My Field" --iterations=5 --type=select