Technical support This forum is closed.
Version 1.x > Technical support > Self registration for public user View modes: 
User avatar
Member
Member
mhchew - 6/22/2006 1:30:19 PM
   
Self registration for public user
Hi,
Is it possible to let the public user self register and the cms will create a user name in the database, and automatic assign the role/permission to this user, based on profile setting?

thanks

rgds

User avatar
Guest
admin - 6/24/2006 12:27:15 PM
   
Re: Self registration for public user
Hello,

Thank you for your message. You need to build a standard ASPX form and use Kentico CMS API to create users and assign them to chosen roles.

using Kentico.CMS.DataEngine;
...

DataClass userObj = new DataClass(“cms.user”);
userObj.SetValue(“username”, “johns”);
userObj.SetValue(“fullname”, “John Smith”);
userObj.Insert();

GeneralConnection cn = new GeneralConnection();
object[,] paramsIdent = new object[ 2, 3 ];
paramsIdent[ 0, 0 ] = "@UserID";
paramsIdent[ 0, 1 ] = userObj.GetValue("userid");
paramsIdent[ 1, 0 ] = "@RoleID";
paramsIdent[ 1, 1 ] = roleId; //set appropriate value here
cn.ExecuteQuery( "CMS.User.AddToRole", paramsIdent );

Best Regards,