The gform_freshbooks_enable_dynamic_field_mapping Gravity Forms filter allows you to enable dynamic field mapping for the ‘Line Items’ setting in a Freshbooks feed. With this feature, you can map form fields to the line item’s unit cost and quantity.
Usage
To enable dynamic field mapping, add the following code to your functions.php
file:
add_filter('gform_freshbooks_enable_dynamic_field_mapping', '__return_true');
Parameters
- No parameters for this filter.
More information
See Gravity Forms Docs: gform_freshbooks_enable_dynamic_field_mapping
Examples
Enable dynamic field mapping
Enable dynamic field mapping for the ‘Line Items’ setting in the Freshbooks feed.
add_filter('gform_freshbooks_enable_dynamic_field_mapping', '__return_true');
Disable dynamic field mapping
If you want to disable dynamic field mapping, return false
instead of true
.
add_filter('gform_freshbooks_enable_dynamic_field_mapping', '__return_false');
Enable dynamic field mapping for a specific form
Only enable dynamic field mapping for a specific form with ID 5
.
function enable_dynamic_field_mapping_for_form_5($is_enabled) { if (rgar($_POST, 'id') == 5) { return true; } return $is_enabled; } add_filter('gform_freshbooks_enable_dynamic_field_mapping', 'enable_dynamic_field_mapping_for_form_5');
Enable dynamic field mapping based on user role
Enable dynamic field mapping only for users with the ‘administrator’ role.
function enable_dynamic_field_mapping_for_admins($is_enabled) { $current_user = wp_get_current_user(); if (in_array('administrator', $current_user->roles)) { return true; } return $is_enabled; } add_filter('gform_freshbooks_enable_dynamic_field_mapping', 'enable_dynamic_field_mapping_for_admins');
Enable dynamic field mapping based on a custom condition
Enable dynamic field mapping only if a custom condition is met.
function enable_dynamic_field_mapping_based_on_custom_condition($is_enabled) { // Your custom condition $custom_condition = true; if ($custom_condition) { return true; } return $is_enabled; } add_filter('gform_freshbooks_enable_dynamic_field_mapping', 'enable_dynamic_field_mapping_based_on_custom_condition');