7

I need to show the list of the content created by the currently logged-in user. How do I do this with the Views module?

migrated from stackoverflow.com Nov 24 '11 at 23:24

This question came from our site for professional and enthusiast programmers.

13
  1. Create View on Content, and click "save and edit".
  2. Add necessary fields. Title, body, post date, etc.
  3. Expand the "Advanced" pane.
  4. Add new Contextual filter.
  5. Check "Content: Author uid"
  6. When the filter value is NOT in the URL -> Provide default value -> User ID from logged in user (if you are putting this View in profile pages, better choose "User ID from URL")
  7. Apply and save.
  8. :)

Update:

Here is a short list for Views 2:

  1. Create a View on node as primary table.

  2. Add necessary fields as you want.

  3. Click Add new argument(Little plus sign under arguments pane). Check "User: UID" and click add.

  4. When the argument is not given, choose to use a default argument, and set it to logged in user.

Update 2:

If you want to restrict access to own content, see https://drupal.stackexchange.com/a/41899/1899

  • how do you do that in views 2? – frazras Aug 6 '12 at 14:53
  • 1
    updated answer :) – AyeshK Aug 6 '12 at 18:13
3

You can also achieve this by the following in your view:

Add Relationship "Content: Author" and check require relationship, then add a filter for "User: Current" and chose Is the logged in user.

This is probably a better option if you only want to display posts created by logged in user, as it is url independent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.