views:

31

answers:

1

A very standard example of the problem that I am facing is that of a custom content say blog type. Now there is a view namely "My Blog Posts". In that view i take the argument as User:uid. Now, for the link part i simply write the code below:

global $user; and send $user->uid as the argument to User:Uid. This give me link for "My Blog Posts" or the blog posts of the logged-in user

What I want is a view like "His Blog Posts". So, if i visit the profile of some other user. There should be a tab in his profile "Blog Posts by Me".

So for that i need to have the UID of the user whose profile I am visiting. So, how can I get this parameter from URL of his profile or somevhere else.

+4  A: 

A common way would be to get the parameter from the url if your urls are in the format user/UID you can use arg(1) to get the UID.

Jeremy French
+1 - Just to clarify: Even if one uses path aliases like e.g. 'user/[user-name]/profile', `arg()` will still operate on the 'original' Drupal path, not on the alias. So it can be used reliably to extract elements from known paths' like 'node/[nid]' or in this case 'user/[uid]'
Henrik Opel
thanx for d extra information.. the solution worked
abhishekgupta92
In addition to `arg(1)` to get the UID of the user, you can also use `menu_get_object('user')` to get a fully loaded user object. cf. http://api.drupal.org/api/function/menu_get_object/6
mongolito404