Again I interact with Sitecore. This time because the project (still the same as before) is published in other server (not our server) and we have so limited access to it, I took liberty to create a small “Admin Panel”-like place for my client to get the data they need.
The basic requirement is simple. Our client just want to see the list of users that have been registered in their web. Before this page is exist, we tried to look on the after registration page through google analytics. Then it will cause us a lot of time and a lot of effort with a minimal result. Then the requirement come and as I have written earlier, they want to see the list of users.
The main thing in list of users must be email address, username, and registration date. The hardest yet still easy part to get is the registration date of every user. Basically, sitecore CMS automatically saved the registration date of every user. But, only those who are allowed that can see it in the back end. Since I am not the super admin, I made some modification on the way my users register. Using the code below, I can record the date of register.
On the “Admin Panel” then use the code below.
List<User> listUser = Sitecore.Security.Accounts.UserManager.GetUsers().Where(o => o.Name.ToLowerInvariant().StartsWith("YourDomainName\\") && !o.Name.ToLowerInvariant().Contains("anonymous")).ToList(); aRepeater.DataSource = listUser; aRepeater.DataBind();
Well, It is quite easy. But it bug me quite a short time to figure that up. The bad thing is that the custom property can only contains string. Means we can really use the date time easily. If you encounter the same requirement, please create the custom property from the start. Why? Because it is needed for the user custom property data to be recorded from the start. If you have already create a registration and encounter the same problem as me, doing the same method, then handle your exceptions well.
This custom property on user is quite useful too. One can store some things inside, as long as it is a string. Well, if you have other way to access it, then please share it 🙂