function uif_plus_save_profile2_fields in User Import Framework Plus 7
Save fields of profile2 types
Parameters
object $account:
array $profile_fields:
1 call to uif_plus_save_profile2_fields()
- uif_plus_update_user in ./
uif_plus.module - Common function for updating users based on types of fields as provided by contrib modules.
File
- ./
uif_plus.module, line 481 - Advanced user import from a CSV file.
Code
function uif_plus_save_profile2_fields($account, $profile_fields) {
foreach ($profile_fields as $type_name => $fields) {
$profile = profile2_load_by_user($account, $type_name);
if (empty($profile)) {
$profile = profile2_create(array(
'user' => $account,
'type' => $type_name,
));
}
foreach ($fields as $field_name => $field) {
$profile->{$field_name} = $field;
}
profile2_save($profile);
}
}