Try our conversational search powered by Generative AI!

Is there any possibility to delete automatically CustomerContact if MemberShip User is deleted in the Cms?



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?

Apr 03, 2015 11:09

Hi Sviatlana,

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:

using System.Web.Providers;

namespace AlloyTech.Business
    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">
    <clear />
    <add name="CustomMembershipProvider" type="AlloyTech.Business.CustomMembershipProvider, AlloyTech"
          connectionStringName="EPiServerDB" enablePasswordRetrieval="false" enablePasswordReset="true"
          requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
          maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
          passwordAttemptWindow="10" applicationName="/"/>

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 :)

Apr 04, 2015 0:00

Thank you very much!

Apr 06, 2015 7:59
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.