Fix GDPR checkbox handling for unchecked state in CF7 forms#178
Merged
davidperezgar merged 1 commit intotrunkfrom Mar 30, 2026
Merged
Fix GDPR checkbox handling for unchecked state in CF7 forms#178davidperezgar merged 1 commit intotrunkfrom
davidperezgar merged 1 commit intotrunkfrom
Conversation
…unchecked When a CF7 checkbox was unchecked, CF7 submitted an empty array for the field. The !empty() guard in get_merge_vars() treated that as "no value", leaving $value as the CF7 field name string (e.g. "extra-info"). That non-empty string then caused gdpr_accept to be evaluated as true in Clientify's create_entry(), meaning every contact was marked as having accepted GDPR even when they had not. Switching to isset() ensures the actual submitted value (empty array → empty string after implode) is used, so gdpr_accept correctly resolves to false for unchecked and true for checked checkboxes. Adds two regression tests covering both states. Fixes #176 https://claude.ai/code/session_01L5SX14n8w68mnppe99jPDg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed a bug in the Contact Form 7 integration where unchecked GDPR checkboxes were not being properly handled when submitting data to the CRM. The issue was that empty arrays (submitted by CF7 for unchecked checkboxes) were being treated as falsy values, preventing the field from being included in the merge variables.
Key Changes
get_merge_vars()from! empty()toisset()to properly handle empty arrays submitted by CF7 for unchecked checkboxestest_get_merge_vars_gdpr_unchecked()to verify that unchecked GDPR checkboxes result in an empty string valuetest_get_merge_vars_gdpr_checked()to verify that checked GDPR checkboxes properly pass through the label textImplementation Details
The fix distinguishes between:
[], which should map to an empty string''in the CRM fieldBy using
isset()instead of! empty(), the code now correctly processes both states, ensuring GDPR consent fields are always included in the CRM submission with the appropriate value.https://claude.ai/code/session_01L5SX14n8w68mnppe99jPDg