Try our conversational search powered by Generative AI!

Listing Site Members

Vote:
 

Hi,

In one of our project we have a user section in the site. The users can register to the site and create articles, comment on articles.
The users have some additional properties (profile picture, date of birth, etc) in addition to the default ones.

We are implementing this using EPiServerProfile class.

Now the issue we are facing is how and where to display all the profiles in the CMS so that the WebAdmins can moderate them. Is there a built-in way to do this?

Thanks
Pankaj

 

 

#118704
Mar 12, 2015 9:30
Vote:
 

Hi, Pankaj, 

It should be that this oldie still works, might be that you'll still need some modifications though:

http://world.episerver.com/blogs/Magnus-Rahl/Dates/2010/11/Plugin-to-edit-Profile-properties-in-Edit--Admin/

#118707
Mar 12, 2015 11:06
Vote:
 

Working with user profiles can be quite tricky.

To get a user profile, you could do:

var epiProfile = EPiServerProfile.Get(username)

To get a profile of all users, you would have to get all users first, and then call EPiServerProfile.Get() inside the foreach loop.

Other way around is to call:

var profiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);
foreach (ProfileInfo profile in profiles)
{
    ProfileBase profileBase = // tricky part: convert ProfileIfo to ProbileBase
    var epiProfile = EPiServerProfile.Wrap(profileBase);
}

The things get tricky if you have to make profiles searchable. For example, show me all users which are 30-40 years old.

If you don't have to use EPiServerProfile class, I think you'll have more success with creating some custom table and making your own implementation.

#118711
Mar 12, 2015 11:37
Vote:
 

Hi Dejan, thanks for you input.

Now the question is where and how do I list all these profiles in the CMS. Do I need to create a pagetype for this and add a page based on that page type in the page tree. Then I will list all the profiles in that page.

I want webAdmins to browse through them.

Thanks
Pankaj

#118716
Mar 12, 2015 12:13
Vote:
 

Also does EPiServer Community module will be helpfull in the above scenerio?

#118718
Mar 12, 2015 12:21
Vote:
 

Hi, Pankaj, 

On the link I've sent you, you have the solution that is integrated into admin -> search for users or groups. It's presented by user.

However, if you need an advanced search by profile values, then the best option is to create and admin tool. That's basically a page you can put anything to.

This is a quick and easy example: http://jondjones.com/epi-server-tutorial-how-to-create-a-custom-admin-plug-in-in-less-than-5-minutes/

#118722
Mar 12, 2015 12:47
Vote:
 

I don't think installing EPiServer Community just for the sake of this functionality pays off. It's a big solution, with its own membership providers and lots of more functionality you basically don't need. IMO, it would be an overhead.

#118724
Mar 12, 2015 12:48
Vote:
 

If you just want to see them in admin mode, then you can check the link Marija sent you.
If you need to create your own solution using the code I posted, then you can create a plugin: http://www.frederikvig.com/2009/10/creating-an-episerver-plugin/
This article is for EPiServer 5, but the logic is the same. Things haven't changed much since then :)

If you don't want to create additional tables in epi database, but don't want to use EPiServerProfile either, you can store profile information as EPiServer pages (one page per user profile).
Profile information should be public anyway?

#118725
Mar 12, 2015 12:49
Vote:
 

EPiServer pages give you the most flexibility.
You can control who can view / edit / administer pages.
You can use the API you're already familiar with (IContentLoader / IContentRepository).
EPiServer pages are indexed by built-in EPi search, if you decide to use EPiFind, even better :) You don't have to hit the database and can do all kind of filtering.
Just make sure you organize them nicely in epi. You don't want to end up with 1 000 pages under a single node :)

#118729
Mar 12, 2015 13:18
Vote:
 

Thanks Marija and Dejan for your valuable inputs.

I think taking the EpiServer Page route for user profiles make sense.

So as soon as user registers I will register them using MemberShip class as below, and based on the ID I will create an EpiServer page for them.

Membership.CreateUser("username", "password", "email");

Is this what should be done?

Thanks
Pankaj

#118730
Mar 12, 2015 13:28
Vote:
 

Correct.

After you created the user, you should create a profile page, and log-in the user automatically.

FormsAuthentication.SetAuthCookie(username, true);
PrincipalInfo.CurrentPrincipal = PrincipalInfo.CreatePrincipal(username);
#118732
Edited, Mar 12, 2015 13:33
Vote:
 

I am able to creat the pages for the user, what do you suggests in terms of organizing them in a page tree.

How can I save them under container page type and not under start page.

#118739
Mar 12, 2015 16:50
Vote:
 

That depends on the number of users.

You can have a container page under start page called Users, and then container pages A, B, C, D, etc. (first letter of the username), and user profile page below.

For example: Start/Users/J/John-Doe

Not long ago, I blogged about something very similar: http://dcaric.com/blog/importing-archived-articles-from-legacy-system-into-episerver-cms

I had to import the content as EPiServer pages and use a similar tree structure.

Hope this helps :)

#118745
Mar 12, 2015 22:13
Vote:
 

I am creating the profile pages for all the users while registration.

I want to save the profile page reference (ContentReference) along with other profile information. I am able to save LinkURL with the lifo but ContentReference gives me an error.

Thanks
Pankaj

#119105
Mar 20, 2015 16:54
Vote:
 

Where are you saving that page reference? Can you show us the code?

Thanks

#119107
Mar 20, 2015 16:58
Vote:
 

Code below

var profilePage = _contentRepository.GetDefault<UserProfilePage>(initialContainerPage.ContentLink);
            profilePage.Name = registrationInfo.Firstname + " " + registrationInfo.Lastname;

            profilePage.FirstName = registrationInfo.Firstname;
            profilePage.LastName = registrationInfo.Lastname;
            profilePage.UserEmail = registrationInfo.Email;
            profilePage.FBID = registrationInfo.FBID;

            _contentRepository.Save(profilePage, SaveAction.Publish, AccessLevel.NoAccess);

ProfileBase curProfile = ProfileBase.Create(registrationInfo.Email);
                curProfile.SetPropertyValue("FirstName", registrationInfo.Firstname);
                curProfile.SetPropertyValue("LastName", registrationInfo.Lastname);

                curProfile.SetPropertyValue("ProfileLink", profilePage.LinkURL);
#119120
Mar 21, 2015 10:44
Vote:
 

I've opened web.config, and added the following value inside profile / properties

<profile defaultProvider="DefaultProfileProvider">
    <properties>
        ...
        <add name="ProfileLink" type="EPiServer.Core.PageReference, EPiServer"/>
    </properties>
    <providers>
    ...
    </providers>
</profile>

And here's the code for saving /reading the profile link:

var profile = ProfileBase.Create("admin@localhost.com");

profile.SetPropertyValue("FirstName", "John");
profile.SetPropertyValue("LastName", "Doe");
profile.SetPropertyValue("ProfileLink", ContentReference.StartPage);

profile.Save();

var pageReference = profile.GetPropertyValue("ProfileLink") as PageReference;

Instead of PageReference, maybe you could store the seo friendly URL?

But I'm not sure why you need both UserProfilePage and ASP.NET profiles?
You could use the UserProfilePage as a replacement for ASP.NET profile.

Hope this helps :)

#119213
Mar 24, 2015 14:01
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.