Try our conversational search powered by Generative AI!

Henrik Buer
Mar 30, 2011
  4019
(4 votes)

Additional profile information as a single dll plugin

I’m sure many of you has written plugins to let editors/admins edit additional fields in the user profiles. This was a feature in CMS 4 but was removed in CMS 5. Many of my customers (and myself) wondered  why since this feature was widely used and it’s so easy to implement. Anyhow… I’ve gotten tired of doing the same thing in every site that I build so I decided to do a plugin that I just drop in the bin folder.I’ve written a configurable plugin that plugs in in the SidSettingsArea, i.e you get an extra tab in your “Edit user” or “My settings” page. This tab gives you the ability to edit fields in the profile that otherwise wouldn’t be visible.

image

It’s possible to configure what fields should appear and you should also specify translations in your language files for the labels (XPath //languages/language/profile/-profile property- )

As I sad this is a single dll plugin. I used Johan Olofssons excellent blog post for this. Other then that it’s pretty straight forward. The controls are added dynamically in OnInit() to a PlaceHolder depending on your configuration. The ascx-file looks like this:

<%@ Control Language="C#" AutoEventWireup="true" 
CodeBehind="Profile.cs" Inherits="Profile.Profile" %>

<asp:Panel ID="DefaultView" runat="Server" CssClass="epi-padding">
    <div class="epi-formArea">
        <div class="epi-size10">
            <asp:PlaceHolder runat="server" ID="plhControls" />
        </div>
    </div>
</asp:Panel>

 

I inherit from EPiServer.PlugIn.IUserSettings which gives you the LoadSettings() and SaveSettings() methods where you can manipulate a EPiServerProfile-object belonging to the selected user.

 

Configuration is easy. Just add a key to your appSettings-section. The values are the names from the profile properties in web.config separated by commas “,”.

<add key="ProfileFieldsToRender" value="FirstName,LastName,Title,Address,ZipCode,Company" />

For the moment only textboxes are rendered. Perhaps it could be useful to render more complex edit controls in the future?

 

Compiled version (CMS 6, .Net 4.0) here

Drop the dll in your bin folder and don’t forget to add the key to appSettings and to modify the language file to your needs.

You'll find the source code here

Mar 30, 2011

Comments

Henrik Buer
Henrik Buer Mar 31, 2011 08:00 PM

Damn! Now I see that Magnus Paulsson already has a blog post similar to mine... but there are some differences so now you have two sets of code to choose from :-)

Here's Magnus post:
http://world.episerver.com/Blogs/Magnus-Paulsson/Dates/2010/11/Plugin-to-edit-Profile-properties-in-Edit--Admin/

Please login to comment.
Latest blogs
Why C# Developers Should Embrace Node.js

Explore why C# developers should embrace Node.js especially with Optimizely's SaaS CMS on the horizon. Understand the shift towards agile web...

Andy Blyth | May 2, 2024 | Syndicated blog

Is Optimizely CMS PaaS the Preferred Choice?

As always, it depends. With it's comprehensive and proven support for complex business needs across various deployment scenarios, it fits very well...

Andy Blyth | May 2, 2024 | Syndicated blog

Adding market segment for Customized Commerce 14

Since v.14 of commerce, the old solution  for adding market segment to the url is not working anymore due to techinal changes of .NET Core. There i...

Oskar Zetterberg | May 2, 2024

Blazor components in Optimizely CMS admin/edit interface

Lab: Integrating Blazor Components into Various Aspects of Optimizely CMS admin/edit interface

Ove Lartelius | May 2, 2024 | Syndicated blog

Anonymous Tracking Across Devices with Optimizely ODP

An article by Lead Integration Developer, Daniel Copping In this article, I’ll describe how you can use the Optimizely Data Platform (ODP) to...

Daniel Copping | Apr 30, 2024 | Syndicated blog

Optimizely Forms - How to add extra data automatically into submission

Some words about Optimizely Forms Optimizely Forms is a built-in add-on by Optimizely development team that enables to create forms dynamically via...

Binh Nguyen Thi | Apr 29, 2024