Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Created January 11, 2013 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevewithington/4512039 to your computer and use it in GitHub Desktop.
Save stevewithington/4512039 to your computer and use it in GitHub Desktop.
Mura CMS: How to use the user's email address as the username. This would make it unnecessary to collect the username on the form itself.
<cfscript>
// place this in the theme's eventHandler.cfc and reload the application
public any function onBeforeUserSave(struct $) output=false {
var user = arguments.$.event('userBean');
user.setUsername(user.getEmail());
// you could also add custom errors like so
var hasError = false;
// then do some validation of input
// .. validation would go here ..
// if validation fails, add an error
if ( hasError ) {
user.getErrors().myCustomError = 'This user has a problem';
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment