1

I am using profile 2 module to manage users profile related information. so far I am having two tabs

  1. My Accounts
  2. Customize the tabs takes me to two different URLs
    i.e (mydomain.com/users/user-name/edit/Customize)
    (mydomain.com/users/user-name/edit/MyAccounts)

My question is, can I make this into one tab and make these two different pages to display in one single page?

Thanks alot

1 Answer 1

1

Hide the tab on the user account page.

function MY_MODULE_menu_alter(&$items) {
  $items['user/%user_category/edit/profile']['access callback'] = FALSE;
}

Then, merge the profile2 form with the user account form itself :

/**
 * Implements hook_form_FORM_ID_alter() for the user edit form.
 */
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);
  }
}

From http://www.jide.fr/english/add-profile2-form-directly-on-the-user-edit-form

1
  • @user1414193 great. Then choose the correct answer by clicking the tick icon below the vote up/down buttons.
    – niksmac
    Mar 6, 2013 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.