UID is null when saving anonymous user

Created on 25 April 2018, about 7 years ago
Updated 16 May 2025, 3 days ago

When adding a new user anonymously, CM fires hook_campaignmonitor_subscribe(), which is picked up by:

function campaignmonitor_local_campaignmonitor_subscribe($list_id, $email) {
  // Add local record.
  $uid = campaignmonitor_get_uid_from_email($email);
  campaignmonitor_local_dbmerge($uid, $list_id);
}

However, $uid will come back null and the operation will fail. This is my workaround but isn't likely to be correct:

function campaignmonitor_local_campaignmonitor_subscribe($list_id, $email) {
  // Add local record.
  $uid = campaignmonitor_get_uid_from_email($email);
  if (isset($uid) && is_numeric($uid)) {
    campaignmonitor_local_dbmerge($uid, $list_id);
  }
}

For the moment it prevents the user from being told the subscription failed (it actually has updated remotely at this point).

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States aangel

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024