I've been working with the included user "profiles" plugin and ran into a roadblock earlier this week.
I needed to add an "interests" value, selected using a set of checkboxes. Adding the checkboxes to the two profile.xml documents was easy (one controls the 'required' popups, the other actually generates the checkboxes).
The problem was that since the checkboxes added to the various forms was a set of checkboxes, the data returning to be processed was in an array, and the profiles.php document couldn't handle that, not storing any value at all. For a while I looked at the available parameter filters, but that was a dead end.
So I examined the goals and purposes of both the "profiles" plugin and my own long-term plans and determined:
A) the profiles plugin is the only system I am aware of and/or intend to develop that needs to access the #__user_profiles database table.
B) for my purposes, I can safely assume that any array value stored into that database would be required to be an array once recovered from the database.
So I added two small routines into profiles.php:
In the method onContentPrepareData() I added to the foreach loop that restored the stored info back into $data:
Code:
if( preg_match( "~^\[.*\]$~", $v[1], $value ) )
$data->profile[ $k ] = json_decode( $value[0] );
This identifies anything stored in a json format and translates it back into an array.
Then, in the method onUserAfterSave(), I replaced the contents of its foreach loop with:
Code:
if( is_array( $v ) )
$tuples[] = '('.$userId.', '.$db->quote('profile.'.$k).', '.$db->quote(json_encode($v)).', '.$order++.')';
else
$tuples[] = '('.$userId.', '.$db->quote('profile.'.$k).', '.$db->quote($v).', '.$order++.')';
which json encodes any array value which needed to be stored in the DB.
It's tested well, so, not wanting to modify the core files on a live site, I restored the original profiles plugin disabled it, and replaced it all with a duplicate custom plugin which includes my changes.
I think the supporting assumptions are broad enough to be acceptable by the Joomla community at large, and it's certainly proving to be a very useful patch for me, so I'd like to recommend it to be considered for the next Joomla release. (At the very least, it should probably be discussed in the wiki's "Creating a profile plugin" article.)