Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active August 29, 2015 14:25
Show Gist options
  • Save stevewithington/d157d5fff714fb1cabf1 to your computer and use it in GitHub Desktop.
Save stevewithington/d157d5fff714fb1cabf1 to your computer and use it in GitHub Desktop.
Mura CMS: How to email user notification after being activated
<cfscript>
// Mura CMS example of how to send notifications to users after they've been activated
public any function onAfterUserCreate($) {
user = arguments.$.event('userBean');
// By default, we're going to set all newly created users to 'inactive' ...
// you could also add the user to a group, etc. here if you wanted to as well
user.set('inActive', 1).save();
}
// IMPORTANT: this assumes a custom class extension attribute for 'User/Default' called 'activeNotificationSent' exists and default value is '0'
public any function onAfterUserSave($) {
user = arguments.$.event('userBean');
if ( !user.get('inActive') && !YesNoFormat(user.get('activeNotificationSent')) ) {
user.set('activeNotificationSent', 1).save();
arguments.$.getBean('userUtility').sendActivationNotification(user);
}
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment