Skip to content

Commit 76d6268

Browse files
committed
gppa-populate-acf-relationships.php: Fixed issue where error choices would be treated as actual choices which could result in odd behavior such as the current post being used.
1 parent 0ba1bfc commit 76d6268

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

gp-populate-anything/gppa-populate-acf-relationships.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin URI: http:///gravitywiz.com.com/documentation/gravity-forms-populate-anything/
99
* Description: Populate each related post as a separate choice when populating data from an ACF Relationship custom field.
1010
* Author: Gravity Wiz
11-
* Version: 0.1
11+
* Version: 0.2
1212
* Author URI: http://gravitywiz.com
1313
*/
1414
add_filter( 'gppa_input_choices', function( $choices, $field ) {
@@ -17,10 +17,15 @@
1717
return $choices;
1818
}
1919

20+
if ( rgars( $choices, '0/gppaErrorChoice' ) ) {
21+
return $choices;
22+
}
23+
2024
$new_choices = array();
2125

2226
foreach ( $choices as $choice ) {
23-
$post_ids = explode( ',', $choice['value'] );
27+
$post_ids = array_filter( explode( ',', $choice['value'] ) );
28+
2429
foreach ( $post_ids as $post_id ) {
2530
$new_choices[] = array(
2631
'value' => $post_id,

0 commit comments

Comments
 (0)