Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Created October 17, 2014 21:51
Show Gist options
  • Save stevewithington/4e16768a61a9818f4487 to your computer and use it in GitHub Desktop.
Save stevewithington/4e16768a61a9818f4487 to your computer and use it in GitHub Desktop.
Mura CMS : Example of how to create a content item when updating a User
<cfscript>
public any function onAfterUserSave($) {
// reference to new user bean
var user = arguments.$.event('userBean');
// reference to old user bean
//var oldUserBean = arguments.$.getBean('user').loadBy(userid=user.getUserID());
// reference to content item that will be the parent of the 'User' page
var parentbean = $.getBean('content').loadBy(title='Reps');
if ( !parentBean.getIsNew() ) {
var cBean = $.getBean('content')
.loadBy(remoteid=user.getUserID())
.setValue('parentid', parentbean.getContentID())
.setValue('title', user.getFName())
.setValue('remoteid', user.getUserID())
.setValue('categories', user.getCategoryID())
.save();
}
}
</cfscript>
@manking109
Copy link

Is there a way to do this on user creation?

@manking109
Copy link

Yes change onAfterUserSave to onAfterUserCreate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment