My problem is as follows the path user/%user_uid_only_optional/profile is not displayed. If I try a variation of this and instead of having user, I replace user with usr the menu items is displayed. I know there was an issue with the page callback and I understand the issue of why it didnt work. That a boolean variable is not an expectable parameter for the page callback.

  • Line 1: line one is taken from the pro development book.

  • Line 2: line two shows the title (the title is displayed this line works)

  • Line 3: description is correct i checked syntax

  • Line 4: the page callback seems fine unless this isn't the correct format. I am quite sure that it follows what is in the

  • Line 5: the number of arguments are needed is one. Since I have only one %

  • Line 6: access arguments seems to be ok i checked the different permission in drupal under users and that is the edit person that i

  • Line 7: I looked at the menu type and it discusses at the parents level if you want to use the local version of the menu you type

    $items['usr/%currentuser/edit'] = array(
        'title' => 'Profile', // The link text
        'description' => 'My Profile',
        'page callback' => 'editprofile', // the function to be called when link is clicked [below]
        'page arguments' => array(1), // arguments for the callback function 'profile_use_page'
        'access arguments' => array('edit own profile'),
        'type' => MENU_NORMAL_ITEM,
        'menu_name' => 'user-menu', // You'll need to have a menu named my_menu for this to work
                                  // If not specified, it will default to 'navigation'
    function editprofile($user_id) {
      return 'user_id'. $user_id;
  • Did you change your user admin path?
    – 4life
    Aug 9, 2013 at 9:55
  • Because your page callback is a Boolean instead of a function maybe?
    – Clive
    Aug 9, 2013 at 10:30
  • Maybe you could edit your question to include the code changes you've made following that reading? If its still not working, of course
    – Clive
    Aug 9, 2013 at 11:10
  • Please edit the question to make it a question. As it is, it's only code and the title just states a fact.
    – apaderno
    Aug 9, 2013 at 13:28

2 Answers 2


From https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7:

"page callback": The function to call to display a web page when the user visits the path. If omitted, the parent menu item's callback will be used instead.

So page callback has to be omitted to fallback on the parents callback or has to be a function.

  • @Alex which part of the documentation are you confused about in particular?
    – Clive
    Aug 9, 2013 at 10:57
  • I would advise reading through the docs again as something hasn't quite stuck - a Boolean can never be a valid value for a page callback so I'm not sure how this is working for other paths. Some other custom code interfering with menus perhaps? Whatever it is its a fluke, that shouldn't happen as you have an invalid page callback
    – Clive
    Aug 9, 2013 at 11:04
  • You need to read the docs properly, your code doesn't match up with what the docs tell you to do. There are too many errors and mis-understandings in your code to reasonably answer in a single question here. Start your code from scratch, and go through the docs with each line that you write of your new code, making sure it matches up to the extensive documentation for each item property - that's the only way you'll learn what you need to know here. I mean this in a completely friendly tone by the way, these things take a bit of time to learn
    – Clive
    Aug 9, 2013 at 12:03
  • Also this should help: drupal.stackexchange.com/questions/62473/…
    – Clive
    Aug 9, 2013 at 12:06
  • I updated my answer
    – Alex
    Aug 9, 2013 at 16:56

There is a typo in the code shown by the book: It should be user/%user_uid_optional/profile.

Even if you correct that, the code is not working. In fact, when you use that wildcard, you are telling to Drupal that user could be followed by a user ID or nothing, and then by profile. If it is followed by a user ID, the path is fine (e.g. user/1/profile), but when there isn't a user ID the path would become user//profile.

If you look at the code used by blog_menu(), you will notice it defines the following menu items.

  $items['blog/%user_uid_optional'] = array(
    'title' => 'My blog',
    'page callback' => 'blog_page_user',
    'page arguments' => array(1),
    'access callback' => 'blog_page_user_access',
    'access arguments' => array(1),
    'file' => 'blog.pages.inc',
  $items['blog/%user/feed'] = array(
    'title' => 'Blogs',
    'page callback' => 'blog_feed_user',
    'page arguments' => array(1),
    'access callback' => 'blog_page_user_access',
    'access arguments' => array(1),
    'type' => MENU_CALLBACK,
    'file' => 'blog.pages.inc',

In your case, the path should be user/%user/profile, in the same way the Blog module is using blog/%user/feed.

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.