您如何使用profile_save_profile?
foreach ($users as $user) { //list of users to act on
$by_user = views_get_view_result('attendance', 'page_3', array($user->uid)); //view containing info about this user
$edit = array('profile_attendance_short_term' => substr(count($by_user) / count($general), 0, 5)); //calculation
profile_save_profile($edit, $user->uid, 'Fencing Information', TRUE); //update user profile???
}我做错了什么?
编辑:这也失败了:
$edit = array('profile_attendance_short_term' => 9001);
profile_save_profile($edit, user_load(3), 'Fencing Information', TRUE);发布于 2009-08-18 18:13:04
我认为问题在于您将$register (最后一个参数)指定为TRUE。这仅在创建新帐户时使用,因此,如果设置,则只能保存注册页上可用的配置文件字段,这可能不是您想要的。
因为它不是必需的参数,所以可以忽略它。
当谈到编辑的格式时,如果来自表单的值来自于某个表单,那么它需要与$form_state['values']相同的格式,例如:
<?php
$edit = array(
'fencing_style' => 'Aggressive',
'favorite_weapon' => 'sabre',
'left_handed' => FALSE,
);
profile_save_profile($edit, $user, 'Fencing Information');发布于 2009-08-18 16:40:19
查看profile_save_profile函数,它似乎希望$user被传入,而不是$user->uid -所以尝试按如下方式修改您的调用:
profile_save_profile($edit, $user, 'Fencing Info', TRUE); https://stackoverflow.com/questions/1291140
复制相似问题