diff --git a/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php b/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php index a86b551..79037b1 100644 --- a/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php +++ b/includes/acf/acfe/form-actions/cwps-acf-acfe-form-action-contact.php @@ -2578,6 +2578,9 @@ public function tab_mapping_accordion_group_add() { $choices[ $group['id'] ] = $group['title']; } + // Add choice to represent using a custom hook for the group id + $choices[0] = 'civicrm_profile_sync_acfe_dynamic_group hook'; + // Add Group choices and modify Field. $group_field['choices'] = $choices; $group_field['search_placeholder'] = ''; @@ -6055,6 +6058,11 @@ public function form_group_save( $contact, $group_data ) { } } + // If group_id is zero, attempt to set it the result of a filter + if ( $group['group_id'] == 0 ) { + $group['group_id'] = apply_filters( 'civicrm_profile_sync_acfe_dynamic_group', $group ); + } + // Skip if there's no Group ID. if ( empty( $group['group_id'] ) ) { continue;