Skip to content

Commit c75fe1d

Browse files
authored
gpnf-hide-empty-columns.php: Fixed an issue withsnippet not working for fields having data stored on sub field IDs like Name, Address, etc.
1 parent ad94f1d commit c75fe1d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

gp-nested-forms/gpnf-hide-empty-columns.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,13 @@ function gpnfHecColumnHasValue( fieldId, entries ) {
163163

164164
function gpnf_hec_column_has_value( $field_id, $entries ) {
165165
foreach ( $entries as $entry ) {
166-
if ( rgar( $entry, $field_id ) ) {
167-
return true;
166+
foreach ( $entry as $key => $value ) {
167+
// Match $field_id or subfield IDs (For fields like Name, Address, etc).)
168+
if ( preg_match( '/^' . preg_quote( $field_id, '/' ) . '(\.\d+)?$/', $key ) ) {
169+
if ( ! rgblank( $value ) ) {
170+
return true;
171+
}
172+
}
168173
}
169174
}
170175
return false;

0 commit comments

Comments
 (0)