The Caldera Forms action caldera_forms_entry_saved runs after a form entry is created, but before it is finalized. At this point data from fields are available, and the submission status is pending. This creates a opportunity to modify one field value based on another field’s value or external API call, before the submission is finalized.
In this example
Caldera_Forms::get_field_data() is used to get the value of one field, and then if a conditional is passed,
Caldera_Forms::set_field_data() is used to change the value of another field.
Where Does This Code Go?
When using WordPress hooks to customize Caldera Forms or other plugins you should not modify the plugin files, or you will lose your changes when you update the plugin. Instead you should create a small plugin to hold the custom code. It's easy, learn how here.
Technically you can add the custom code to your theme's functions.php, but then you will not be able to change your theme and keep these customizations.