Storing and using information about latest user profile modification.

This article describes how to store timestamp of latest user profile modification (like signature or avatar change) and how you could use it later in the webparts and controls.
There is one field in CMS_User table which might seem suitable for this task – UserLastModified. However, it is the system field and is updated on each user login. This field is not intended for this purpose. The custom field is the solution we are searching for.

1) You can add the custom field (attribute) to the "User - Settings" system table in Site Manager -> Development -> System tables. Here under fields tab add new attribute, let’s say "UserProfileModified" of type "Date and time" and disable "Show attribute in the editing form" setting.

2) Then you could edit web part ~\CMSModules\Membership\Controls\MyProfile.ascx.cs and here add the following line to the end of the editProfileForm_OnBeforeSave handler method, approx. at line #154:

editProfileForm.BasicForm.DataRow["UserProfileModified"] = DateTime.Now;

This will ensure storing of current timestamp when the profile is updated using MyAccount webpart (Personal settings tab) and also in CMS Desk / My Desk / My profile...
Please note that making backup before making changes to our default webparts and controls is always recommended.

3) Afterwards, you could use the UserProfileModified in the ORDER BY and WHERE condition expressions of some webpart based on repeater to list the users with latest changed profiles. For example the “Users viewer” webpart can be easily used for this task.
WHERE condition should be also defined to filter out the null values (e.g. “UserProfileModified IS NOT NULL”), because some user profiles, mostly those already existing, could have this timestamp undefined.

See also:

Applies to: Kentico CMS 4.x
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.