-
-
Save nguyenthanhxuan/9581297 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_menu_alter(). | |
*/ | |
function MY_MODULE_menu_alter(&$items) { | |
$items['user/%user_category/edit/profile']['access callback'] = FALSE; | |
} | |
/** | |
* Implements hook_form_FORM_ID_alter() for the user edit form. | |
* Merge the profile2 form with the user account form itself : | |
*/ | |
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment