Managing User Beans
Function List
General Overview
The Mura API uses user beans as its way to read, create and modify site members.
Read
To read a site member from the database, call the userManager.read() function. The function takes only one parameter; userID
<cfset userBean = application.userManager.read(userID)>
Once you have read the content bean, you have access to all of its attributes.
<cfoutput>
#userBean.getFName()#<br>
#userBean.getLName()#<br>
#userBean.getUsername()#<br>
<!--- get an extended attribute --->
#userBean.getValue('drivers_license')#
</cfoutput>
Create
To create a user, first get an empty user bean.
<cfset userBean = application.userManager.getBean()>
Now we have to set the required attributes. If these attributes aren't set, Mura will throw an error on save.
<cfset userBean.setSiteID('default')>
<cfset userBean.setFName('Eddie')>
<cfset userBean.setLName('Ballisty')>
<cfset userBean.setUsername('eballisty')>
<cfset userBean.setPassword('secret-pass')>
<cfset userBean.setEmail('me@mydomain.com')>
<cfset userBean.save()>
Update
To update a user, first read the user bean.
<cfset userBean = application.userManager.read(userID)>
Now modify the desired attributes.
<cfset userBean.setEmail('me@mydomain.com')>
<cfset userBean.setValue('drivers_license', 'BAA88AA9')>
<cfset userBean.save()>
Delete
To delete a user, first read the user bean.
<cfset userBean = application.userManager.read(userID)>
Now delete.
<cfset userBean.delete()>