custom code to run after a user is registered

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.

This forum is for discussing mojoPortal development

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.

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.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
7/3/2008 12:04:54 PM
Gravatar
Total Posts 10

custom code to run after a user is registered

i want custom code to run after a user is registered.

where can i add this code in mojoportal?

thanks

7/3/2008 2:18:00 PM
Gravatar
Total Posts 18439

Re: custom code to run after a user is registered

Hi femi,

I implemented a solution today to make this easy for you. Its only in my svn sandbox at the moment and I have other things I'mnot ready to merge to trunk yet, but I will get this into trunk over the weekend.

Basically there is an event fired when a user registers and now I have implemented a provider model for handlers of this event so you can plug your custom handler in with a config file and implement it in your own custom project. An example implementation that doesn't do anything is like this:

using System;
using System.Configuration.Provider;
using System.Collections.Generic;
using System.Text;
using mojoPortal.Business;
using log4net;

namespace mojoPortal.Business.WebHelpers.UserRegisteredHandlers
{

public class DoNothingUserRegisteredHandler : UserRegisteredHandlerProvider
{
private static readonly ILog log
= LogManager.GetLogger(typeof(DoNothingUserRegisteredHandler));

public DoNothingUserRegisteredHandler()
{ }

public override void UserRegisteredHandler(object sender, UserRegisteredEventArgs e)
{
if (e == null) return;
if (e.SiteUser == null) return;

// do nothing
log.Debug("DoNothingUserRegisteredHandler called for new user " + e.SiteUser.Email);
}
}
}

You would have yours in your own namespace but you inherit from mojoPortal.Business.WebHelpers.UserRegisteredHandlers.UserRegisteredHandlerProvider

Config files go in /Setup/ProviderConfig/userregisteredhandlers

Its just a text file with .config extenstion like this:

<?xml version="1.0" encoding="utf-8" ?>
<UserRegisteredEventHandlers>
<providers>

<add name="DoNothingUserRegisteredHandler"
type="mojoPortal.Business.WebHelpers.UserRegisteredHandlers.DoNothingUserRegisteredHandler, mojoPortal.Business.WebHelpers"
description="This is a placeholder, do not delete this one. There must always be at least on provider in the collection. " />


</providers>
</UserRegisteredEventHandlers>
 

Hope you get the idea from this code example.

Like I said, its not in svn trunk yet but will be in there over the weekend and then you will be able to implement your code.

Best,

Joe

 

You must sign in to post in the forums. This thread is closed to new posts.