0

I am using Profile 2.

When the user clicks the 'Edit My Profile' tab, I would like its destination to be:

/user/175/edit/about-you

Where about-you is a Profile2 type.

How do I change the path of the tabs?
I am also using TabTamer, but this module does not let you change the path, only the label and enable/disable the link.

EDIT
I have tried the below code in template.php with no results.(after changing the theme name)

function THEMENAME_menu_alter(&$items) {
  $items['user/%/edit'] = $items['user/%/edit/about-you'];
  unset($items['user/%/edit']);
}
  • please see this codeexpertz.com/blog/drupal/…. It might be of some help – Shreya Shetty Jul 10 '18 at 10:49
  • Thanks Shreya Shetty, I have tired the code in the question edit above with no results. Could it be the use of the % for the UID? – IamOnStage Jul 11 '18 at 8:57
0

You can do this by custom module.For this please use below code.First you need to create custom menu using hook_menu.

/**
* Implements hook_menu().
*/
function custom_menu() {
 $items['user/%/edit/about-you'] = array(
  'title' => 'About You',
  'page callback' => 'edit_about_you',
  'page arguments' => array(1),
  'access callback' => TRUE,
 );
return $items;
}

Now You need to write page callback for this menu item.

function edit_about_you($uid){
  $profile = profile2_load_by_user($uid,'profile_type'); // or by default main
  $form_state = form_state_defaults();
  form_load_include($form_state, 'inc', 'profile2_page');
  return entity_ui_get_form('profile2', $profile, 'edit', $form_state);
}

This will return profile edit page for user.Now you need to redirect user when click Edit My Profile tab for this you can user hook_init for that. Check your path argument and redirect user to new created path.

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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