I’ve developed a custom module that enables administrators to approve new users. When a user is approved the module sends a custom welcome e-mail. Everything worked fine in former versions of the DNN platform, but after upgrading to 07.03.04 the user got two welcome e-mails: In addition to the custom e-mail, the default DNN welcome e-mail was send to the user.
The custom module used the following source code to approve a user:
// Approve user (user is a UserInfo instance) user.Membership.Approved = true; // Update user UserController.UpdateUser(portalId, user); // Send custom welcome e-mail // ... |
After digging into the source code of the DNN platform, I found out that the logic to send the default DNN welcome e-mail was moved from the UI to the business logic (see this commit on GitHub) and there seems to be no way to use the new business logic in a way that it does not send the default welcome e-mail. In the end, I used reflection to access an internal method to suppress sending the e-mail:
// Approve user (user is a UserInfo instance) user.Membership.Approved = true; // Supress DNN default approval e-mail which is automatically send // when user is updated (calling UserController.UpdateUser()) // after approved flag changed from false to true var confirmApprovedMethod = typeof (UserMembership).GetMethod("ConfirmApproved", BindingFlags.Instance | BindingFlags.NonPublic); if (confirmApprovedMethod != null) confirmApprovedMethod.Invoke(user.Membership, null); // Update user UserController.UpdateUser(portalId, user); // Send custom welcome e-mail // ... |
Hope this helps someone who is facing the same problem.