I want to modify the userpages with some changes:

  1. change the page-title
  2. hide some or all of the local taks items (the tabs)
  3. display some user-infos
  4. insert a view

Here is how I want to solve it:

  1. use THEMENAME_preprocess_page() to change the title
  2. use THEMENAME_menu_local_task() to hide the tabs
  3. use the user-profile.tpl.php to display user infos
  4. create a view and use views_embed_view()

Is there a better way of doing that? Should I consider using page--user.tpl.php or a combination?

Edit: concerns Drupal 6

  • Regarding point 2: do you just want to hide the tabs, or make the underlying pages inaccessible? May 23, 2011 at 20:07
  • Hiding them should be enough.
    – nonsenz
    May 24, 2011 at 7:54

2 Answers 2

  1. Yes, THEMENAME_preprocess_page() is fine for this, but one could argue that it's better to implement hook_user when $op == 'view'. That way you would make the change available for all themes (who knows you will be adding a mobile theme a couple of months from now?).
  2. I wouldn't use THEMENAME_menu_local_tasks() for this, but instead do $variables['tabs'] = ''; in THEMENAME_preprocess_page(). Of course, only do this for the user page, otherwise you will lose the tabs on all pages.
  3. Yes, use user-profile.tpl.php to print out variables. If you need additional variables, fetch them in THEMENAME_preprocess_page() and add them to the $variables array to make them available in your template. Depending on what you need to do, see also user-profile-category.tpl.php, user-profile-item.tpl.php and their respective preprocess functions.
  4. Yes, that's an option. You can also create a block display of that view and enable the block on the user page.

I recommend not to use multiple page templates (like page-user.tpl.php) if you can. When you do, a simple change to page.tpl.php will often need to be applied to all other page templates as well, which is a bore.


To change the title for profile page use hook_username_alter(), or the other method as mentioned in the other answer.

  • That hook doesn't change only the title of the profile page: It changes the username that is shown for the user, in every place where the username is shown.
    – apaderno
    Oct 1, 2012 at 14:14

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.