Notification of when user first creates account

Apr 19, 2011 at 5:08 PM

Hi, Whats the best way to be notified when a user first creates an account via facebook authentication ?

Thanks for any help,


Apr 20, 2011 at 5:12 PM

Hi Ben,

At the moment there is not way to get a direct notification from my mod... though you could use a handler? I think its something like this...

OnCreated<OpenAuthenticationPart>((c, o) => {
// Do Stuff

I will take a look when im home as I havent got orchard at work.

Cheers, Nick

Apr 22, 2011 at 12:56 PM

Hi, got that to work fine in the handler (code is below - the mail sending part would need to be pulled out for production obviously) :


OnCreated<IUser>((context, user) =>
     var BccEmailAddress = ConfigurationManager.AppSettings["BccEmailAddress"];
     var mailMessage = new MailMessage();
     mailMessage.BodyEncoding = Encoding.UTF8;
     mailMessage.IsBodyHtml = false;
     mailMessage.Subject = ConfigurationManager.AppSettings["RegistrationEmailSubject"];
     mailMessage.Body = ConfigurationManager.AppSettings["RegistrationEmailBody"];
     mailMessage.From = new MailAddress(ConfigurationManager.AppSettings["FromEmailAddress"]);
     if (!string.IsNullOrEmpty(BccEmailAddress)) mailMessage.Bcc.Add(BccEmailAddress);
     var client = new SmtpClient();

Apr 22, 2011 at 5:24 PM

Ahh cool!!.. to check for the provider... You could do this as well...

OnCreated<OpenAuthenticationPart>((context, part) => {
   if (part.Record.HashedProvider == ProviderHelpers.GetHashedProvider(Provider.Facebook))
     // Do Stuff