drupal :how to pass current userid as argument
i need to display开发者_开发百科 the contents added by that user...
i have designed a view to display the result.. but it displays the results of all users..... i need to display the contents added by that user...
when i pass the argument of userid it works, but is there any dynamic way to do that....
If all you need is a list of nodes by the current user, the easiest way is to use the User:Current filter. Just click the [+] next to 'Filters', choose 'User:Current' from the list, click the 'Add' button and set the filter to 'Yes'.
The argument-method as described by streetparade (using the 'User: Uid' argument) is useful if you want users to see the list of other users as well. Suppose that your view's url is www.example.com/my-content. If you add a user argument, user #3 could see what user #7 has posted on www.example.com/my-content/7. If you want that, use the argument. If you do not want that, use the filter.
Use This
<?php
global $user;
$userId = $user->uid;
?>
You can access all this way
(source: chromaticsites.com)
精彩评论