Created
January 11, 2013 16:30
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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