0

I send newsletters from my Drupal-7 website using Simplenews module. I have a general category, that has all my site users and it is the category I use the most.
Although, some of the newsletters are sent to a smaller target group (women-only, men-only etc).
My problem is that when users click on the unsubscribe link from a newsletter that is not from my general category, then they unsubscribe from this category only and not the general.
What I want to achieve, is that when a user is unsubscribed from any newsletter category, to automatically unsubscribe him from the general category also.

0

I think it should work. Use hook_simplenews_unsubcribe_user which will

/**
 * Invoked if a user is unsubscribed from a newsletter.
 *
 * @param $subscriber
 *   The subscriber object including all subscriptions of this user.
 *
 * @param $subscription
 *   The subscription object for this specific unsubscribe action.
 *
 * @ingroup subscriber
 */
function hook_simplenews_unsubscribe_user($subscriber, $subscription) {

}

Add this in your custom module. I think $mail and $tid will be available in $subscrption variable.

function module_simplenews_unsubscribe_user($subscriber, $subscription) {
  simplenews_unsubscribe_user($mail, $tid, FALSE, 'website');//$tid -s your genral category tid.
}
  • thank you for your answer!so, with the FALSE attribute, they unsubscribe automatically from the general category also? I want when they unsubscribe from any other category, to also get unsubscribed from my general category from my custom module – Argiris A Jul 1 '16 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.