In this tutorial, you will learn how to create a profile editing tool within Episerver v6. Recently a client wanted a way for content editors to have the ability to add a profile image within an Episerver v6 powered blog whenever they published a new post. There are two ways to implement this functionality in Episerver. My first idea was to create a user page type so content editors can add profiles into the CMS. On the BlogItemPageType
a property picker could be defined so people could attach a profile to the page. This idea would work, however, it would also just be restricted to the blog plug-in.
Instead, I went with the approach of extending the Episerver profile provider, adding an extra image field and creating an admin plug-in to set the properties. The reason why I went this route, was that one of my main requirements was that admins should be the only people to update the profile image. This is the main reason why I went the admin plug-in route
Create a custom property in the web.config
to store the image.
To add etra info to the profile store, you will need some config. This is added to the web.config
:
For this project, I only need to set profile images for a very small subset of the content editors. The first part of the plug-in will return a list of all the users so an administrator can pick whose profile they want to update. In our situation, only certain content editors will need a profile image, so I restrict my profile list to users in the WebEditors
:
After we have a list of users, we need to add an image picker. A few months ago I detailed how to do this with sample code (available here), so I won't go over it again 😊
After we have an image and access to the profile ID to update, we need to store the image in Episerver. In order to do this, we will use the EPiServerProfile
class. After an editor selects which profile they want to update, the username will be passed into an update method.
For Epiferver to store the profile information, use SetPropertyValue()
and then, critically, the Save()
method. If you do not call save, the information will not persist 🤪. Code example shown below:
When the profile information is updated, it can be accessed using this code:
Now customize the page as required.  Its easy to extend the plug-in to add in any other custom profile attributes if needed.  As always you can download the plug-in from my GitHub here. Happy Coding 🤘