Skip to content

Commit 474a8b3

Browse files
committed
gw-update-posts.php: Fixed issue where snippet returned ID instead of value when GPPA dynamically populates post field.
1 parent 00a1386 commit 474a8b3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

gravity-forms/gw-update-posts.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,16 @@ function acf_get_field_object_by_name( $field_name, $group_name = false ) {
279279
* @return mixed
280280
*/
281281
public function return_ids_instead_of_names( $value, $field, $template_name, $populate, $object, $object_type, $objects, $template ) {
282+
// Check if this is for the specific form we want.
283+
if ( $field->formId != $this->_args['form_id'] ) {
284+
return $value;
285+
}
286+
287+
// Don't want to return IDs for post objects used in the populates field dynamically using GPPA.
288+
if ( rgar( $field, 'gppa-values-enabled' ) === true && rgar( $field, 'gppa-values-object-type' ) === 'post' ) {
289+
return $value;
290+
}
291+
282292
if ( strpos( $template, 'taxonomy_' ) === 0 ) {
283293
$taxonomy = preg_replace( '/^taxonomy_/', '', $template );
284294
$terms = wp_get_post_terms( $object->ID, $taxonomy, array( 'fields' => 'ids' ) );

0 commit comments

Comments
 (0)