Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. /*** Implements hook_menu ***/
  2.     function ea_custom_menu() {
  3.       $items['users/%user'] = array( //the %user will be used as argument for the page callback
  4.         'title' => t('User Profile'),
  5.         'page callback' => 'ea_custom_render_userpage',
  6.         'page arguments' => array(1), //zero base array. This tells hook menu to first load user with the specified uid specified by %user parameter.
  7.         'access callback' => 'user_access', //so non-onwer can also view it
  8.         'access arguments' => array('access content'),
  9.       );
  10.       return $items;
  11.     }
  12.    
  13.     /**** page callback for users/%user ****/
  14.     function ea_custom_render_userpage($user) {
  15.        //you now have accessed to the user object
  16.        drupal_set_message('<pre>' . print_r($user, TRUE) . '</pre>');
  17.    
  18.        //assemble your output using the values inside $user object
  19.        $output = $user->uid; //etc.. etc...
  20.    
  21.        return $output;
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement