More in this section

Forums / Developing with Sitefinity / Customization of New Letter Subscrition Form Control

Customization of New Letter Subscrition Form Control

2 posts, 0 answered
  1. kiran
    kiran avatar
    13 posts
    Registered:
    04 Jun 2009
    04 Jun 2009
    Link to this post
    Hi,
         I want to subscribe the user to a group for sending news letters while registration.sitefinity provides news letter subscription control but my registration functionality is in different user control,here we provide an check box for the user.If he select that checkbox and click on registration submit button the user have to add to subscription group automatically for sending news letters.

    How can i customize the news letter user control,any suggestions.
    please help!
      
  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    04 Jun 2009
    Link to this post
    Hi kiran,

    It will not be easy to integrate the SubscriptionForm control in your registration.
    It is better to use the DataManager class to subscribe the user to specific group directly in your code.
    This can be accomplished by the following sample code:
    if (checkBox.Checked// the checkbox for subscription 
        string subscriberEmail = "mail@server.com";//yourTextBox.Text; 
        DataManager newsletterManager = new DataManager(); 
        ISubscriber subscriber = newsletterManager.GetSubscriber(subscriberEmail); 
        if (subscriber == null
        { 
            subscriber = newsletterManager.CreateSubscriber(subscriberEmail); 
            subscriber.FirstName = "FirstNameOfUser";//first name of the user 
            subscriber.LastName = "LastNameOfUser";//last name of the user 
     
            newsletterManager.SaveSubscriber(subscriber); 
     
            IGroupSubscriber gSub = null
            // For each subscriber group 
     
            IList list = newsletterManager.GetGroups(""); 
     
            foreach (IGroup group in list) 
            { 
                // this is the group name 
                if (group.GroupName == "Group name user should be subscribed"
                { 
                    gSub = newsletterManager.CreateGroupSubscriberRelation( 
                       group.GroupId, subscriber.SubscriberId); 
                    newsletterManager.SaveGroupSubscribers(gSub); 
                } 
            } 
        } 
    The places where you should enter user information and group name are highlighted with green.

    I hope this helps you.

    Best wishes,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
2 posts, 0 answered