The gform_zap_before_save filter allows changes to be made to the Zapier feed setup before it is saved to the database.
Usage
To apply the filter to all forms:
add_filter('gform_zap_before_save', 'your_function_name', 10, 2);
To target a specific form, append the form id to the hook name (format: gform_zap_before_save_FORMID):
add_filter('gform_zap_before_save_1', 'your_function_name', 10, 2);
Parameters
- $zap (Feed Object): The feed object.
- $form (Form Object): The form object.
More information
See Gravity Forms Docs: gform_zap_before_save
Examples
Change the name of a Zap
This example changes the name of a Zap before it’s saved to the database.
add_filter('gform_zap_before_save', 'change_zap', 10, 2); function change_zap($zap, $form){ $zap['name'] = "Test Zap"; return $zap; }
Add a prefix to a Zap name
This example adds a prefix to the name of a Zap before it’s saved.
add_filter('gform_zap_before_save', 'add_zap_name_prefix', 10, 2); function add_zap_name_prefix($zap, $form){ $zap['name'] = "Prefix - " . $zap['name']; return $zap; }
Change the Zap name based on form ID
This example changes the name of a Zap only for a specific form with ID 1.
add_filter('gform_zap_before_save_1', 'change_zap_for_form', 10, 2); function change_zap_for_form($zap, $form){ $zap['name'] = "Form 1 Zap"; return $zap; }
Disable a Zap for a specific form
This example disables a Zap for a specific form with ID 2.
add_filter('gform_zap_before_save', 'disable_zap_for_form', 10, 2); function disable_zap_for_form($zap, $form){ if ($form['id'] == 2) { $zap['is_active'] = false; } return $zap; }
Change the Zap name based on form title
This example changes the name of a Zap based on the form title.
add_filter('gform_zap_before_save', 'change_zap_name_based_on_form_title', 10, 2); function change_zap_name_based_on_form_title($zap, $form){ $zap['name'] = $form['title'] . " - Custom Zap"; return $zap; }