Created
October 17, 2014 21:51
-
-
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
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> | |
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> |
Yes change onAfterUserSave to onAfterUserCreate
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to do this on user creation?