Try our conversational search powered by Generative AI!

Programmatically update the EPiServerProfile and Community user Email

Vote:
 

EPiServer 7.5 
Community/Relate

Hi - this is what im trying to do:

Update the EPiServer user (EpiserverProfile object) and the community user (IUser) email in code.

All users in my sulotion have an Episerver user (EpiserverProfile) AND a community user (IUser) that is connected - which means that if you update the EPiserver user email via the CMS-Admin UI the correspondent Community user will also be updated.

Now - i can easily update just the Community object (IUser) by cloning the IUser object i wat to update and simply update it by using EPiServer.Common.Security.SecurityHandler -> update. The problem is that i also want the change to be made to the correspondent Episerver user (EpiserverProfile). 

Since the community user email gets automaticly updated when i update the Episerver user email in the Admin UI - i thought that the same thing would happen if i programmatically just updated the EpiserverProfile. So thats what i did:

I collected the user i wanted to update (var profile = new EPiServerProfile(ProfileBase.Create(user.UserName, true))). Then i set a new email to the Email propery on the profile and call Save().

This is what happens:

- I search for the user in the Admin UI.
- In the list of search result - the OLD email still shows.
- If i click on the profile - the NEW email shows.
- The correspondent community user did not get automaticly updated as it would if i updated the EpiserverProfile from the UI.
- If i now press "Save" in the UI however - everything will get updated as i want it.

Why doesnt the EpiserverProfile.Save() method execute in the same way as the "save" button in the UI for a EpiserverUser?

#140850
Nov 02, 2015 10:26
Vote:
 

I would use the Get method to grab the users profile and the save method to update it instead of creating a new?

#144508
Feb 15, 2016 0:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.