4.6 profile.module | profile_save_profile(&$edit, &$user, $category) |
4.7 profile.module | profile_save_profile(&$edit, &$user, $category) |
5 profile.module | profile_save_profile(&$edit, &$user, $category, $register = FALSE) |
6 profile.module | profile_save_profile(&$edit, & |
7 profile.module | profile_save_profile(&$edit, $account, $category, $register = FALSE) |
1 call to profile_save_profile()
File
- modules/
profile/ profile.module, line 236 - Support for configurable user profiles.
Code
function profile_save_profile(&$edit, &$user, $category, $register = FALSE) {
$result = _profile_get_fields($category, $register);
while ($field = db_fetch_object($result)) {
if (_profile_field_serialize($field->type)) {
$edit[$field->name] = serialize($edit[$field->name]);
}
db_query("DELETE FROM {profile_values} WHERE fid = %d AND uid = %d", $field->fid, $user->uid);
db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s')", $field->fid, $user->uid, $edit[$field->name]);
// Mark field as handled (prevents saving to user->data).
$edit[$field->name] = NULL;
}
}
Comments
Param details
Missing documentation:
Parameters
$edit: An array of profile field names as keys and the new values to save as the values (example:
$edit['profile_first_name'] = 'John'
).$user: An object, minimally just an object with the user id (example:
$user->uid=1
).$category a string defining the profile category like 'Personal information'.
$register: Boolean, if this is a new user or not.
Return Value
None
Does Not Work
This thing does not work properly. I had to fetch the fid from profile_fields using the fild name and the update the profile_vales table myself using this fid and the desired hid.
In case you are wondering...
<?php
$category = 'Personal Information';
$account = new stdClass();
$account->uid = 1;
$edit = array(
'first_name' => 'Walter',
'last_name' => 'White',
);
profile_save_profile($edit, $account, $category);
?>
来自 https://api.drupal.org/api/drupal/modules!profile!profile.module/function/profile_save_profile/6