asp.netsitecoresitecore7sitecore-workflow

Triggering a function when administrator enables a user in Sitecore


I'm trying to do a web application in which the user creates a account in the /extranet domain and its disabled initially. When the sitecore admin enables the user account an function should be triggered so that a mail can be sent to the user, But i'm not finding any solution to trigger the code.

This is the code i have used to create the user in /extranet

Membership.CreateUser(mailId, password, mailId, "question", "answer", false, out status);

Solution

  • Please refer: http://techmusingz.wordpress.com/2014/06/15/notify-sitecore-user-on-account-enable/ for a complete example of overriding the corresponding command.

    You will need to replace
    <command name="usermanager:enable" type="Sitecore.Shell.Framework.Commands.UserManager.Enable,Sitecore.Kernel"/>

    with
    <command name="usermanager:enable" type="Sitecore72.Classes.EnableUserNotify, Sitecore72"/>

    You could use the reflected code from Sitecore.Kernel.dll, and append your logic for notification in the Run method - where args.IsPostBack is true, after the user profile has been updated (user.IsApproved = true;)

    This would enable you to retain the message boxes as implemented by sitecore and add the custom functionality you need as well.