Description
Filter the source value of a conditional logic rule before it is compared with the target value.
Usage
add_filter( 'gform_rule_source_value',function( $source_value, $rule, $form, $logic, $entry ) {
// Modify the rule
return $source_value;
}, 10, 5 );
Parameters
- $source_value int|string
The value of the rule’s configured field ID, entry meta, or custom property.
- $rule Rule Object
The current rule object. See the Rule Properties section of the Conditional Logic Object article.
- $form Form Object
The current form meta.
- $logic Conditional Logic Object
All details required to evaluate an objects conditional logic.
- $entry Entry Object
The entry currently being processed, if available.
Example
add_filter( 'gform_rule_source_value', function( $source_value, $rule, $form, $logic, $entry ) {
// Changing the field value when evaludating conditional logic with source field id 3, and form id 1.
if ( $form['id'] == '1' && $rule['fieldId'] == '3' ) {
$source_value = 'my custom field value';
}
return $source_value;
}, 10, 5 );
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Since
This filter was added in Gravity Forms v2.6.2.
Source Code
This filter is located in GFFormsModel::evaluate_conditional_logic() in forms_model.php