【发布时间】:2012-06-25 11:27:26
【问题描述】:
如何在一个页面中添加 profile2 表单与 drupal 用户配置文件表单? 我试试这个钩子,但它对我不起作用:(
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);
}
}
【问题讨论】: