Module does not work - use Mailjet API instead

Created on 20 June 2018, over 6 years ago
Updated 17 October 2024, about 1 month ago

Hi Stefan,

Thanks for your module that provides a useful webform component.
I think that your module should be much more used. So I suggest it could to be enhanced and light.

The part that does not work, for me, is in
function mailjet_webform_subscription_webform_submission_insert($node, $submission).

I could use your module for the webform component and added my own hook_webform_submission_insert in a custom module.

I would suggest to use API provided by the Mailjet module

/**
* Implements hook_webform_submission_insert().
*/
function mailjet_webform_subscription_submission_insert($node, $submission) {
...

// Find the Customer e-mail and Newsletter field IDs. Only for example with a single e-mail and single list:
foreach ($components as $component) {
if ($component['type'] == 'email' && $component['form_key'] == 'mail') {
$client_email_cid = $component['cid'];
}
if ($component['type'] == 'mailjet_checkbox') {
$mailjet_checkbox_cid = $component['cid'];
}
}

if ($submission->data[$mailjet_checkbox_cid]['subscription_checkbox'] == '1') {
$client_email = $submission->data[$client_email_cid][0];
$list = $submission->data[$mailjet_checkbox_cid]['contact_list'];
}

if (!empty($client_email)) {

mailjet_properties_sync();
$mailjet = mailjet_new();

$add_params = array(
'method' => 'POST',
'Action' => 'Add',
'Force' => TRUE,
'Addresses' => array($client_email),
'ListID' => $list,
);

$mailjet->resetRequest();
$response = $mailjet->manycontacts($add_params)->getResponse();

if ($response && $response->Count > 0) {
watchdog(...);
...
}

}

}

Hope this may help.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France chipway

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