✨ include email_id in group membership
This commit is contained in:
parent
8dab2377f5
commit
5a424771fd
5 changed files with 86 additions and 13 deletions
|
@ -172,16 +172,20 @@ class GroupMailingList extends BaseMailingList {
|
|||
* Add a contact to this mailing lists related group.
|
||||
*
|
||||
* @param int $contactId
|
||||
* @param ?int $contactEmailId
|
||||
*
|
||||
* @return void
|
||||
* @throws \Civi\Mailinglistsync\Exceptions\MailinglistException
|
||||
*/
|
||||
protected function addContactToGroup(int $contactId): void {
|
||||
protected function addContactToGroup(int $contactId, int $contactEmailId = NULL): void {
|
||||
try {
|
||||
\Civi\Api4\GroupContact::create()
|
||||
$query = \Civi\Api4\GroupContact::create()
|
||||
->addValue('contact_id', $contactId)
|
||||
->addValue('group_id', $this->group['id'])
|
||||
->execute();
|
||||
->addValue('group_id', $this->group['id']);
|
||||
if ($contactEmailId) {
|
||||
$query->addValue('email_id', $contactEmailId);
|
||||
}
|
||||
$query->execute();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
if ($e->getMessage() === 'DB Error: already exists') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue