I am on Drupal 6, and I needed to implement "Content Profile".

We want the users to gain access to their "profile" in edit mode, so we will provide a link with the following pattern: /user/%/edit/. There, the users see the merged view (user/password + content profile).

The thing is setting the following options to "true":

  • Redirect on User Edit page
  • Disable the normal User Edit tab

I want to add an extra tab ("my favorites") on top of this page, so that user can access his "flagged" content.

I am banging my head on my keyboard since this morning: No tabs are displaying. I used hook_menu_alter(), added a view as shown here, but to no avail.

Do you have any ideas?

  • 1
    May you show the code you are using for hook_menu_alter()? If your code is doing something wrong, it is not possible to know it, without seeing it.
    – apaderno
    Commented Dec 29, 2011 at 19:28

3 Answers 3


You don't need to alter a menu if you want to add one. Use hook_alter().

How do i use hook_menu to add a menu item into an exisiting menu contains a lot of useful ideas to takle down not showing menus.

  • If he is altering what shown in /user/%/edit/, then he needs to use hook_menu_alter().
    – apaderno
    Commented Dec 29, 2011 at 19:29
  • Hello, I am afraid my code will not help much... I am scratching my head to make it work actually, so you may be right. Truth is I am quite new to Drupal, and it seems like it's hard to debug what's in the $items variable passed in parameters of MYTHEME_menu_alter(). I have been using dpm(), dvm(), drupal_set_message(), without result. Only watchdog('MYMODULE_menu_alter',serialize($items)); gave some results, but the content is quite cryptic. Also, when I run drush cc all, I can get as output the print_r($items); , but this output is too long and is truncated...
    – Cypher
    Commented Dec 29, 2011 at 21:48
  • By the way, I forgot to mention that I use "Account Profile" to have the original account page + content profile merged in the same page. I don't know if it helps...
    – Cypher
    Commented Dec 29, 2011 at 21:54
  • 1
    You have to clear the cach to make drupal call hook_menu(_alter) . Just enter drush cc all on the command line. To see the output of dpm youneed to login as admin or give the user the right to access devel information. Look at api.drual.org for the description of hook_menu to understand the datastructure.
    – BetaRide
    Commented Dec 30, 2011 at 7:21
  • Thank you BetaRide, this is what I did actually. I am logged in as admin (uid=1). And I do run the drush command you mentioned (as I wrote in the post above)... Still no clue...
    – Cypher
    Commented Dec 30, 2011 at 9:06

There are two modules that try to solve this problem, but I cannot tell you if they work as advertised. I recommend that you try it out on a test site first.

  • Thank you for your reply, but it is off-topic. If you read me carefully, I already set up "Account profile" and it works as advertised.
    – Cypher
    Commented Dec 30, 2011 at 5:27
  • Sorry if my answer wasn't helpful to you. However your question does not mention Account Profile (you only did so in a comment to someone else's question), so please don't tell me that I should read more carefully while in fact you could be asking better questions. Did you know you can update your question to add more information? Commented Dec 30, 2011 at 20:42

// $Id: content_profile_edit.module,v 2009/09/23 11:56:50 Solide Exp $

 * @file
 * Allows exposure and processing of content_profile node fields at user modification

 * Implementation of hook_form_alter().

function content_profile_edit_form_alter(&$form, &$form_state, $form_id) {
    global $user;
  if (($form_id == 'user_profile_form') && ($user->uid != 1)) {
    require_once drupal_get_path('module', 'node') .'/node.pages.inc';

    // Allow other modules to customize the used profile types, so modules
    // can easily customize the modification form.
    $default_types = content_profile_get_types('names');
    $form += array('#content_profile_edit_use_types' => $default_types);
    foreach ($form['#content_profile_edit_use_types'] as $type => $typename) {
            //content_profile_edit_modify_profile_form($type, $form, $form_state);
            content_profile_edit_modify_profile_form($typename, $form, $form_state);
    $form['#theme'][0] = 'user_profile_form';


 * Helper function to return all available fields for a particular content type.
 * @param string $type
 *   The content type to return fields for.
 * @return array
 *   Associated fields for the given content type.
function _content_profile_edit_get_fields($type) {
  $typeinfo = content_types($type);
  return $typeinfo['fields'];

 * Returns an array of selectable form elements that may be hidden, mostly containing CCK fields.
 * @param string $type
 *   A content type to get the select elements for.
 * @return Array
 *   An array of fields suitable for use in a select field.
function _content_profile_edit_get_field_select($type) {
  $fields = module_exists('content') ? _content_profile_edit_get_fields($type) : array();
  $return = array();
  if (!module_exists('auto_nodetitle') || auto_nodetitle_get_setting($type) != AUTO_NODETITLE_ENABLED) {
    $return['title'] = t('Title');
  foreach ($fields as $fieldname => $info) {
    if (!$info['required']) {
      $return[$fieldname] = drupal_ucfirst($info['widget']['label']);
  $return['other'] = t('Other form elements (except for required CCK fields)');

  return $return;

function content_profile_edit_modify_profile_form($type, &$form, &$form_state) {
  // Fetch profile node and add in its form.

  $node = content_profile_load($type, $form['#uid']);
  if (!$node)
    $node = array('uid' => $form['#uid'], 'type' => $type);

  // Get the original node form.
  $node_form = drupal_retrieve_form($type .'_node_form', $form_state, $node);
  drupal_prepare_form($type .'_node_form', $node_form, $form_state);
  foreach($node_form as $key => $value) {
    if(in_array($key, array('#id', 'form_id', 'form_token', '#token', '#action', '#parameters', 'author'))) continue;
    if(in_array($key, array('#submit', '#validate'))) {
      $form[$key] = array_merge($form[$key], $value);

   $form[$key] = $value;
   //$form_state['rebuild'] = true;
  //$form['author']['name']['#default_value'] = $form['account']['name']['#default_value'];
 // unset($form['#submit']);
  $form['#submit'][] = 'content_profile_edit_user_modify_submit';
  $form['#validate'][] = 'content_profile_edit_user_modify_validate';
 //echo '<pre>';  print_r($form['#submit']);echo '</pre>';
  // Remove submit handler here, we only want it to be triggered on save, not on preview.
  // We will call it ourselves from our save handler.

  //$form['#submit'] = array_diff($form['#submit'], array('user_profile_form_submit'));
  //$form['#validate'] = array_diff($form['#validate'], array('user_profile_form_validate'));
  //$form['#theme'] = 'user_profile_edit';
  // Also remove node validation.  We will call node_validate ourselves from content_profile_edit_user_modify_validate()

  $form['#validate'] = array_diff($form['#validate'], array('node_form_validate'));
 // unset($form['#validate']);


 * Validates the user edit form
function content_profile_edit_user_modify_validate($form, &$form_state) {

//echo '<pre>';print_r($form_state);die;
 // echo $form_state['clicked_button']['#id'];die;
  // Make sure the language setting saves.
  if ($form_state['clicked_button']['#post']['language']) {
    $form_state['values']['language'] = $form_state['clicked_button']['#post']['language'];

  user_profile_form_validate($form, $form_state);
  $node = $form['#node'];
  if($form_state['clicked_button']['#id'] === 'edit-submit'){
      $node = $node->_account;
  require_once drupal_get_path('module', 'node') .'/node.pages.inc';
  $node->changed = strtotime(date("Y-m-d H:i:s"));
  node_validate($node, $form);

 * Submits the user edit form
function content_profile_edit_user_modify_submit($form, &$form_state) {
/*echo '<pre>';
//echo '<pre>';print_r($form);die;
  if($form_state['clicked_button']['#id'] == 'edit-submit'){
        $node = $form['#node'];
    //echo '<pre>'; print_r($form_state['values']['_account']);die;
     // user_profile_form_submit($form, &$form_state);
      global $user;

    //  $node->uid = $user->uid;

      $node = node_submit($node, $form);      
     // print_r($node);die;
      node_save($node, $form);

make an info file yourself.

Your Answer

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

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