2

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);
4

2 に答える 2

3

$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-18T18:13:04.663 に答える
0

profile_save_profile 関数を見ると、$user->uid ではなく $user が渡されることを想定しているようです。次のように呼び出しを変更してみてください。

profile_save_profile($edit, $user, 'Fencing Info', TRUE); 
于 2009-08-18T16:40:19.280 に答える