If you were handcoding this, you would create a menu path using hook_menu, with %uid as the second parameter. And the page_callback
value of the menu item would be the function rendering the user page. You will then use hook_user_login
to set the redirect rule.
If you were doing this using contrib modules, I suggest you looking into profile2, it comes with a built in functionality where each user has their own profile page.
edited:
The last sentence on your question, makes me led to think that the user/%uid path needs to be accessible users/visitors other than the owner. So let's here is how you would do it.
- Create your custom module, let's call it
ea_custom
for the sake of
this example.
Add hook_menu and page_callback to your ea_custom.module and register the path for the individual user page.
/* Implements hook_menu */
function ea_custom_menu() {
$items['users/%user'] = array( //the %user will be used as argument for the page callback
'title' => t('User Profile'),
'page callback' => 'ea_custom_render_userpage',
'page arguments' => array(1), //zero base array. This tells hook menu to first load user with the specified uid specified by %user parameter.
'access callback' => 'user_access', //so non-onwer can also view it
'access arguments' => array('access content'),
);
return $items;
}
/**** page callback for users/%user ****/
function ea_custom_render_userpage($user) {
//you now have accessed to the user object
drupal_set_message('
' . print_r($user, TRUE) . '
');
//assemble your output using the values inside $user object
$output = $user->uid; //etc.. etc...
return $output;
}
Additional notes: you can use different methods to get values from entity objects such as user and node. I would recommend you to check entity_metadata_wrapper
for one. Also, instead of using %user, to get user object, you could opt to use %profile2, since you have that module installed, and it will allows you access to fields you have attached to profile type.
wow, I can't seem to format this properly. Here is the paste bin: http://pastebin.com/kiv6GfPN