Error message when there is no list shown other than the default list.

Created on 7 April 2025, 7 days ago

Problem/Motivation

I receive an "'Unable to finish subscription. Please contact website support.'" error when adding a sign up on a form where a default list is configured but no other list is shown.

Steps to reproduce

  1. Install the module and configure API url and key.
  2. Add a Simple Sign up block to a page
  3. In the Simple Sign up configuration chose a default contact list.
  4. Do not select "Show" on any other list (we don't want to give the user the option of signing up to any list other than the default).
  5. Save the block
  6. Attempt to sign up.

Proposed resolution

Alter the code block in SubscribeForm.php:

    // Check if all API call were successful.
    if (!$activecampaign_contact_id || empty($is_in_default_contact_list) || empty($is_in_selected_contact_list)) {
      $this->messenger()->addError(
        $config['failed_message']
        ?? $this->t('Unable to finish subscription. Please contact website support.')
      );
    }

This conditional will always return false in this scenario, as

$is_in_selected_contact_list

will always be empty, as there is no selected contact list.

This conditional should only fail when

$is_in_selected_contact_list

is empty AND a contact list was selected in the sign up form.

Suggest the conditional is changed to:

  // Check if all API call were successful.
  if (!$activecampaign_contact_id || empty($is_in_default_contact_list) || (!$form_state->isValueEmpty('contact_list') && empty($is_in_selected_contact_list))) {
    // ...
  }
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom Leo Pitt

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024