Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Created March 10, 2014 16:05
Show Gist options
  • Save stevewithington/9467954 to your computer and use it in GitHub Desktop.
Save stevewithington/9467954 to your computer and use it in GitHub Desktop.
Mura CMS: These are examples of how to register an event handler/listener for when a user is being saved or updated, and then access the old user bean along with the new user bean.
<cfscript>
// Place these methods in your Site, Theme, or Plugin's eventHandler.cfc
public any function onBeforeUserSave($) {
var newUserBean = arguments.$.event('userBean');
var oldUserBean = arguments.$.getBean('user').loadBy(userid=arguments.$.event('userid'));
// if you want to stuff the oldUserBean in the event
// $.event('oldUserBean', oldUserBean);
// here you could run any comparison logic between the oldUserBean and the newUserBean
}
public any function onBeforeUserUpdate($) {
var newUserBean = arguments.$.event('userBean');
var oldUserBean = arguments.$.getBean('user').loadBy(userid=arguments.$.event('userid'));
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment