Creating A Custom Caldera Forms Processor

Caldera Forms Banner

Creating a custom processor for Caldera Forms, complete with its own UI, is relatively simple. There are several other methods available for processing submission data via a custom PHP or JavaScript callback, which are illustrated here. This article covers the most basic Caldera Forms processor.

Processors are added using the caldera_forms_get_form_processors filter and adding a new array to the multi-dimensional array returned by that filter. In the new array, which defines your processor, in the key “processor” you can set a callback function. This callback function is called when the processor is triggered and is where you do your actual “processing.”

You can also add a key called “pre_processor” that is a callback function that runs in the validation stage of the form processing. The pre-processor can be used to return an er

ror and stop the form from completing submission.

Example Caldera Forms Processors

Caldera Forms Processor To Send Data To A Remote API

Here is a simple Caldera Forms processor plugin with no UI. It simply takes all data from the form submission and sends it to a remote API. If that API returns an error, that error is shown in the form and the processing stops:

Note that theĀ pre_processor callback was used. This allows for the remote API call to validate the submission. All Caldera Forms payment processors and mailing list processors use pre_processor to attempt the purchase or attempt to subscribe the user to a mailing list. That way if that API call fails, for example beacuse of a bad credit card, an error is shown and the form doesn’t complete submission.

Caldera Forms Processor To Save In An Alternative Location

This next example uses the processor callback to save a field’s value as post meta. This processorĀ makes use of the Caldera Forms processor UI so that it can be configured with a post ID and a field to specify the meta value from.

Here is the main processor file:

Notice that the function “my_processor_extra_meta_processor” gets the two settings dynamically based on UI settings. The UI fields are defined in the function “my_processor_extra_meta_processor_fields” where the “id” argument corresponds to the key of the $config array passed to the processor.

That function is used in the config file:

That one line of code generates a complete UI for the processor:
User interface generated for a Caldera Forms processor