Profile events
Profiles in Sitefinity CMS expose the following events to which you can subscribe:
ProfileEventBase
This is the base class for events that notifies for changes in profiles. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Security.Events;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ProfileEventBase>(evt => ProfileEventHandler(evt));
}
public void ProfileEventHandler(ProfileEventBase eventInfo)
{
var userId = eventInfo.UserId;
var membershipProviderName = eventInfo.MembershipProviderName;
var profileId = eventInfo.ProfileId;
var profileProviderName = eventInfo.ProfileProviderName;
var profileType = eventInfo.ProfileType;
}
}
}
In the event handler, you can access the following information:
- The ID of the user associated to the profile.
- The name of the membership provider that the user belongs to.
- The ID of the profile.
- The name of the profile provider.
- The type of the profile.
ProfileCreated
This event fires when a profile is created. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Security.Events;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ProfileCreated>(evt => ProfileEventHandler(evt));
}
public void ProfileEventHandler(ProfileCreated eventInfo)
{
var profile = eventInfo.ProfileId;
var provider = eventInfo.ProfileProviderName;
var type = eventInfo.ProfileType;
var user = eventInfo.UserId;
}
}
}
In the event handler, you can access the following information:
- The ID of the profile.
- The name of the profile provider.
- The type of the profile.
- The ID of the user associated to the profile.
ProfileCreating
This event fires when a profile is being created. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Security.Events;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ProfileCreating>(evt => ProfileEventHandler(evt));
}
public void ProfileEventHandler(ProfileCreating eventInfo)
{
var profile = eventInfo.Profile;
}
}
}
In the event handler, you can access the profile of the user.
ProfileUpdated
This event fires when a profile was modified. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Security.Events;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ProfileUpdated>(evt => UpdatedProfileEventHandler(evt));
}
public void UpdatedProfileEventHandler(ProfileUpdated eventInfo)
{
var profileId = eventInfo.ProfileId;
var provider = eventInfo.ProfileProviderName;
var type = eventInfo.ProfileType;
var user = eventInfo.UserId;
}
}
}
In the event handler, you can access the following information:
- The ID of the profile.
- The name of the profile provider.
- The type of the profile.
- The ID of the user associated to the profile.
ProfileUpdating
This event fires when a profile is being modified. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Security.Events;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ProfileUpdating>(evt => UpdatingProfileEventHandler(evt));
}
public void UpdatingProfileEventHandler(ProfileUpdating eventInfo)
{
var profile = eventInfo.Profile;
}
}
}
In the event handler, you can access the profile of the user.
ProfileDeleted
This event fires when a profile was deleted. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Security.Events;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ProfileDeleted>(evt => DeletedProfileEventHandler(evt));
}
public void DeletedProfileEventHandler(ProfileDeleted eventInfo)
{
var profileId = eventInfo.ProfileId;
var provider = eventInfo.ProfileProviderName;
var type = eventInfo.ProfileType;
var user = eventInfo.UserId;
}
}
}
In the event handler, you can access the following information:
- The ID of the profile.
- The name of the profile provider.
- The type of the profile.
- The ID of the user associated to the profile.
ProfileDeleting
This event fires when a profile is being deleted. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Security.Events;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ProfileDeleting>(evt => DeletingProfileEventHandler(evt));
}
public void DeletingProfileEventHandler(ProfileDeleting eventInfo)
{
var profile = eventInfo.Profile;
}
}
}
In the event handler, you can access the profile of the user.