Skip to content

Commit 2eb6aeb

Browse files
committed
gw-conditional-logic-entry-meta.php: Added support for adding additional runtime entry meta keys.
1 parent f3aee97 commit 2eb6aeb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

gravity-forms/gw-conditional-logic-entry-meta.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function set_rule_source_value( $source_value, $rule, $form, $logic, $ent
151151
$target = $rule['fieldId'];
152152

153153
if ( in_array( $target, $keys ) && $entry ) {
154-
if ( $target === 'payment_status' ) {
154+
if ( in_array( $target, $this->get_runtime_entry_meta_keys(), true ) ) {
155155
// Some payment add-ons do not update the runtime entry but do update the entry in the database.
156156
// Fetch the latest from the database.
157157
$entry = GFAPI::get_entry( $entry['id'] );
@@ -167,7 +167,7 @@ public function gpns_should_evaluate_conditional_logic_on_send( $eval_on_send, $
167167
foreach ( $notifications as $notification ) {
168168
$_notification = gp_notification_schedule()->get_notification( $form, $notification['nid'] );
169169
foreach ( rgars( $_notification, 'notification_conditional_logic_object/rules' ) as $rule ) {
170-
if ( $rule['fieldId'] === 'payment_status' ) {
170+
if ( in_array( $rule['fieldId'], $this->get_runtime_entry_meta_keys(), true ) ) {
171171
return true;
172172
}
173173
}
@@ -176,6 +176,19 @@ public function gpns_should_evaluate_conditional_logic_on_send( $eval_on_send, $
176176
return $eval_on_send;
177177
}
178178

179+
/**
180+
* Get the keys for any entry meta that may be updated during a form submission.
181+
*
182+
* Since these are updated mid-submission, conditional logic in some contexts (like notifications triggered by a feed
183+
* action) will be using a stale entry. Identifying these entry meta keys allows us to ensure special functionality
184+
* to support them.
185+
*
186+
* @return mixed|void
187+
*/
188+
public function get_runtime_entry_meta_keys() {
189+
return apply_filters( 'gwclem_runtime_entry_meta_keys', array( 'payment_status' ) );
190+
}
191+
179192
}
180193

181194
function gw_cl_entry_meta() {

0 commit comments

Comments
 (0)