This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.
Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.
Before posting questions here you might want to review the developer documentation.
Hi,
I am successfully creating new users in my portal in code using the SiteUser class. I'm also adding new users to specific roles and all works very well. I now also need to subscribe a user to a specific newsletter (one which they are entitled to subscribe to). Is there a way I can do this in code? I notice that new users I create aren't subscribed to newsletters which are set for all new users to be subsribed, so I assume that process doesn't happen in the SiteUser class when a new user is saved.
There's a NewsletterHelper class but that doesn't seem to have a lot in it. I wondered if its ClaimExistingSubscriptions(siteUser) method might just subscribe a user to all the newsletters they have available to them (which would be fine) but it doesn't seem to.
Any suggestions?
Thanks
Shameless bump!
mojoPortal is open source and you can get the source code or browse it from the codeplex site and easily find out answers to questions like this by looking at existing code that is used for subscribing to newsletters.
In this case you can find the code of interest in Web/Controls/Subscribe.ascx.cs
Hope that helps,
Joe
Hi Joe,
Thanks for this. I am just picking this issue up again so apologies for the delay! Yes, I realise the source code is available so I took a look at the code behind that user control. I must say I found it a bit difficult to follow in this instance (I kept getting an error about NewsletterHelper.GetAvailableNewslettersForCurrentUser being used as a type instead of a method).
Anyway, I decided it would be easier to do this on the database so wrote a stored procedure to subscribe a user to all newsletters available to a role when they join that role. This can then be triggered off inserts to the mp_UserRoles table so that the whole thing is automated.
My procedure works fine and adds rows to mp_LetterSubscribe, but I notice there's also a table called mp_LetterSubscribeHx which has rows in it relating to subscriptions that have been added manually. What is this table for, and should I add corresponding rows to it from my procedure?
Thanks again,
Michael
mp_LetterSubscribeHx is where we keep a history of when a user opts in or out of the newsletter. Its mainly an audit log so we can see the history if someone claims we are spamming them or that they opted out or never opted in etc.
Thanks Joe,
Very helpful as ever (both that feature and your post!).