我如何使用 drupal 用户配置文件表单在一个页面中添加 profile2 表单?我试试这个钩子,但它对我不起作用:(
function MY_MODULE_form_user_profile_form_alter(&$form, &$form_state) {
if (($type = profile2_get_types('profile')) && $type->userCategory) {
if (empty($form_state['profiles'])) {
$profile = profile2_load_by_user($form['#user'], 'profile');
if (empty($profile)) {
$profile = profile_create(array('type' => 'profile', 'uid' => $form['#user']->uid));
}
$form_state['profiles'][$profile->type] = $profile;
}
profile2_attach_form($form, $form_state);
}
}