Upon completion of a custom payment form I add two user roles, a badge, and two friends. All of those changes work well and populate to the User object and corresponding database tables. When I use the below code (copied and altered from Kentico CMS install) I get IsSubscribed == true, but the user nevers appears to be subscribed. Any ideas?
int newsletterId = 3;
Subscriber sb = SubscriberProvider.GetSubscriber("cms.user", currentUser.UserID);
if (sb == null)
{
// Create new subscriber
sb = SaveSubscriber(); // CreateSubscriber(value[0], itemId);
}
// If subscriber exists and is not subscribed, subscribe him
if ((sb != null) && (!SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId)))
{
try
{
SubscriberProvider.Subscribe(sb.SubscriberID, newsletterId, DateTime.Now, false);
lblTroubledUser.Text = "shoulda been subscribed to newsletter";
}
catch
{
lblTroubledUser.Text = "problem subscribing to newsletter";
}
}
else
lblTroubledUser.Text = (!SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId)) ? "sb is null" : "already subscribed to newsletter!";