Is there any possibility to delete automatically CustomerContact if MemberShip User is deleted in the Cms via Admin interface?
Is there possibility to subscribe to the MemberShip User delete?
DefaultMembershipProvider doesn't have deleted user event, but you can create your own membership provider.I'll use AlloyTech as a sample project, and extend SqlServerMembershipProvider:
1. Inside Business folder, create CustomMembershipProvider:
public class CustomMembershipProvider : DefaultMembershipProvider
public override bool DeleteUser(string username, bool deleteAllRelatedData)
// TODO: cleanup code
return base.DeleteUser(username, deleteAllRelatedData);
2. In web.config, register a new membership provider and set it as default one:
<membership defaultProvider="CustomMembershipProvider" userIsOnlineTimeWindow="10" hashAlgorithmType="HMACSHA512">
<add name="CustomMembershipProvider" type="AlloyTech.Business.CustomMembershipProvider, AlloyTech"
connectionStringName="EPiServerDB" enablePasswordRetrieval="false" enablePasswordReset="true"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
3. In admin mode, if you get an exception when you try to create / delete user, just restart the IIS (or kill IIS Express Worker process from task manager)
That's it. Hope it helps :)
Thank you very much!