Username Password
Bookmark and Share
"Admin Editable" flag for User Profile fields  (#11607)

Although perhaps originally unintended for this purpose, the User Profiling system is great for hanging extra pieces of data against user accounts for use by custom code.

Rather than having to add an extra table, hand-write some sql, remember to purge data when user accounts are deleted etc.. you can simply jump into the User Profiling UI, add a field or two, choose the desired field type and then use the User Profiling API from you custom code in exactly the same way you access default profiling fields.

Just one more way that WebGUI makes your life easier as a developer.

However currently there is a gotcha: Admins are shown all User Profiling fields on the Edit Profile screen, regardless of whether those fields are set as Visible, Editable, Required, etc.. This is because Admins get shown the Edit Profile screen via WebGUI::Operation::User wheres end-users see it via WebGUI::Accout::Profile

This is problematic if you create a field of type Group, DateTime, etc.. because these fields may get overwritten accidentally when the Admin hits Save on a user's Edit Profile screen. For example, if you have a Group field set to a hidden group, that Group won't appear in the drop-down list and hence the first visible group in the list will be chosen instead (e.g. #11586). Similarly, if you have a DateTime field with no value set, the field will default to the current date/time and the NULL value will get overwritten.

A workaround in the case of Group fields is to use Guid, which has the effect of making the field Readonly via the UI. To do this with DateTime you would need to subclass DateTime to create a new readonly version and use that instead.

After discussing with preaction and perlDreamer on IRC, we concluded that the best approach would be to create a new User Profiling per-field option called "Admin Editable" that controls whether or not Admins can edit the field. This option would default to TRUE to preserve existing behaviour, but could be set to FALSE by developers who want to prevent these fields from being accidentally modified.

Ticket Status Pending  
Submitted By patspam  
Date Submitted2010-06-02 
Assigned To unassigned  
Date Assigned 2020-06-03  
Assigned By  
What to improve? WebGUI Beta  
Difficulty 1  
Karma So Far0
Karma Rank0.00
Ticket History
7:50 PM
Ticket created patspam
© 2020 Plain Black Corporation | All Rights Reserved