It would be great to have a possibility to block individual fields based on the user's cookie consent preferences.

Currently, the Cookies Addons module has submodules for blocking blocks (cookies_addons_blocks) and views (cookies_addons_views), but there's no way to block specific fields when users haven't consented to relevant cookie categories.

For example:
- Block video embed fields when user declined marketing cookies
- Hide social media fields when tracking cookies are not accepted
- Block map fields (Google Maps) when functional cookies are declined
- Hide any field that might load third-party content requiring consent

I propose creating a separate sub-module "cookies_addons_fields" that would work exactly like cookies_addons_blocks but for fields, using the same configuration pattern and placeholder replacement logic.

This would complete the cookie consent coverage by adding field-level control alongside the existing block and view level controls.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

scontzen created an issue. See original summary.

_shy made their first commit to this issue’s fork.

_shy’s picture

Version: 1.2.3 » 1.0.x-dev
Status: Active » Needs review
StatusFileSize
new11.98 KB

Also, added a patch with the changes.

guido_s made their first commit to this issue’s fork.

guido_s’s picture

Assigned: scontzen » guido_s
guido_s’s picture

I added some validation for the route and some access checks to make sure users can only get fields and view modes they have access for to not leak any data. Didn't manage yet to do a test in a test site though. Feel free to check again. I will merge this after it has been properly tested in a real drupal environment.

_shy’s picture

Status: Needs review » Reviewed & tested by the community

I tested the functionality with the latest changes on the Drupal website. After accepting the cookies, the field’s content was correctly displayed in place of the placeholder block.
The functionality was verified for both logged-in and anonymous users and tested with different field types.

  • guido_s committed 73116f56 on 1.0.x authored by _shy
    Issue #3532613 by _shy, guido_s, scontzen: Implement Field Blocking...
guido_s’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for testing it again!
I merged it now and we can create a new feature release and update the modules description.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.