This project is read-only.

Editing the User Name in a Custom Module

Topics: Administration, Announcements, Core, Customizing Orchard, General, Installing Orchard, Localization
Apr 30, 2015 at 11:08 AM
In my current Project I have a few custom modules there is a requirement like i need to change the UserName from userpart table in one of my custom Module. May I know is it Possible to modify the usrename in UserPart table, Please send me the sample code to do these changes.
I reffered the ".ContentManager.UpdateEditor(user, this);" method but this is asking for a EditView View model , Please guide me how can i achive this functionlity.

Thanks and Regards,
Sunil M.R.
Apr 30, 2015 at 4:33 PM
You can update the username directly like this:
user.As<UserPart>().UserName = "new user name";
However, keep in mind that every other record that references a user by user name will now be unable to retrieve information about that user as you broke the link between them. For example, Comments store the user by user name, not by user ID. Perhaps it's not an issue, but it's definitely something to be aware of.