I have a custom module let say mymodule. One of the function in this module generates or returns some contents. Forget about what the content is. My question is how could i add this content to user profile page. I tried to override using user-profile.tpl.php file. I could override the theme. But how to add a variable to this page that contains the required content so that i can echo the variable. Is there any preprocessing function that will help

2 Answers 2


Use the hook_menu in your custom module and use MENU_LOCAL_TASK as the type, and the path in your custom module needs to start with user/

function HOOK_menu() {
      $items['user/%user/yourpage'] = array(
        'title' => t('My Tab'),
        'type' => MENU_LOCAL_TASK,
        'page callback' => 'yourmodule_page', //your module page should be a function 
        //'page arguments'
      return $items;

function yourmodule_page()
   $uid = arg(1);
   $user = user_load($uid);
   //use user to get particular content belonging to them
   //return content

You can use the theme preprocess function template_preprocess_user_profile to provide your variables.

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.