Issue #3467876 by renrhaf: Add user registration newsletter subscription...

Closes #3467876.

Adds an opt-in brevo_user submodule that puts a newsletter subscription checkbox on the user registration form. When the user ticks it, they are subscribed to the configured Brevo list(s) through the shared event system (BrevoEvent) — asynchronously via the brevo_create_contact queue by default (registration is never blocked by the API), or synchronously if configured.

Configuration (admin/config/services/brevo/user)

  • Brevo lists — one or more lists, fetched live from the API.
  • Checkbox label / description and checked-by-default (default: unchecked = explicit opt-in, GDPR-friendly).
  • Processing: queue (recommended) or direct.
  • Attribute mapping — JSON mapping Brevo attributes to user fields, e.g. {"FNAME": "field_first_name"}.

Multi-list BrevoEvent

BrevoEvent now takes a list_ids array so a contact can be added to several lists at once. The event system landed in #3588657 but is not yet in a release, so the previous single list_id key is simply replaced (no BC layer needed).

Architecture

Per the base-module direction in #3553922, everything reuses the main module's ContactsApiClientHelper and event subscriber — no separate credentials, and the trigger is overridable through the standard event system. The checkbox is a normal form element, alterable via hook_form_alter. The submodule is opt-in, so sites that only need the email field are unaffected.

Tests & validation

Kernel test: checkbox visibility gating, opt-in / opt-out, multi-list, direct vs queue processing. Unit tests cover the multi-list BrevoEvent. Config schema included.

Validated locally on Drupal 11.3 / PHP 8.3: PHPCS (Drupal, DrupalPractice) and PHPStan clean on the whole module, full unit+kernel suite green (37 tests / 105 assertions), and a live drush check confirmed the checkbox renders on the real registration form (unchecked by default) and a real opt-in reaches the Brevo Contacts API.

Merge request reports

Loading