rakeshakurathi
rakeshakurathi

Reputation: 13

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....

Upvotes: 0

Views: 2300

Answers (2)

streetparade
streetparade

Reputation: 32888

Use This

<?php

global $user;
$userId = $user->uid;
?>

You can access all this way

Drupal UserID
(source: chromaticsites.com)

Upvotes: 0

marcvangend
marcvangend

Reputation: 5642

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.

Upvotes: 4

Related Questions