Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Use API to to subscribe users as 'users' to newsletter instead of new subscriber View modes: 
User avatar
Member
Member
joeh42 - 12/30/2011 9:07:47 AM
   
Use API to to subscribe users as 'users' to newsletter instead of new subscriber
I've noticed that if I go to the newsletters module, I can subscribe users to newsletters.

If I delete a user, his or her subscriptions are removed.

However, the only API sample I have found (http://devnet.kentico.com/Knowledge-Base/E-mail-Engine/How-to-subscribe-user-to-newsletter-using-API.aspx) adds subscribers as new subscribers (not as existing users).

Then if I delete the user, the subscriber is not tied to the user, and the subscription remains active.

How can I use the API to subscribe a user to a newsletter as a 'user'?

Second, does the OnBeforeDelete event in the CustomDataHandler fire when a user is deleted? If so, I can use that to clean up some of my existing subscriptions.

Thanks,
Joe Hoppe

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 1/1/2012 9:40:21 AM
   
RE:Use API to to subscribe users as 'users' to newsletter instead of new subscriber
Hello,

you can realte the user to the Subsciber object (sb) like:

sb.SubsciberType = "cms.user";
sb.SubscriberRelatedID = <userid>;

Yes, you can also use the custom data handler. It is fired for users, too.


Best regards,
Helena Grulichova