There are two problems here:
-
Accessing a plugin custom fields may return a
Stringor anArrayand there isn’t any protection for plugin authors here. If I douser_custom_fields["date_of_birth"] = "2016-05-02"I should ideally always get back aStringif I retrieve the custom fields again. Currently, accessing custom fields may return anArrayif custom fields with the same name and user_id is somehow set around the same time. This is not ideal IMO as either all access to a plugin custom fields will have to be accompanied by a check to see if it is anArrayorStringor a lock has to be used when setting any custom field. -
Maintaining a valid date as a String is not ideal. Initially when I started working on the plugin, we decided to store the date in a
UserCustomFieldinstead ofUser#date_of_birthbecause the requirements for the plugin was simple and we can get away with it even if thedate_of_birthis invalid. Right now, we use the date of birth field in more places and an invalid format will just blow things up. I’ll look to see if I can migrate custom fields intoUser#date_of_birthto ensure consistency in the date format.